﻿$(window).load(function () {
 	$(".loading").fadeOut()
 })
 $(function () {
     var data = {
         "division": [
             {
                 "cc_city": "新城区",
                 "cc_citycode": "150102",
                 "children": []
             },
             {
                 "cc_city": "回民区",
                 "cc_citycode": "150103",
                 "children": []
             },
             {
                 "cc_city": "玉泉区",
                 "cc_citycode": "呼和浩特市美通商贸有限责任公司",
                 "children": []
             },
             {
                 "cc_city": "赛罕区",
                 "cc_citycode": "150105",
                 "children": []
             },
             {
                 "cc_city": "土默特左旗",
                 "cc_citycode": "150121",
                 "children": []
             },
             {
                 "cc_city": "托克托县",
                 "cc_citycode": "150122",
                 "children": []
             },
             {
                 "cc_city": "和林格尔县",
                 "cc_citycode": "150123",
                 "children": []
             },
             {
                 "cc_city": "清水河县",
                 "cc_citycode": "150124",
                 "children": []
             },
             {
                 "cc_city": "武川县",
                 "cc_citycode": "150125",
                 "children": []
             }
         ],
         "storageData": [
             {
                 "cc_name": "呼和浩特市军粮供应服务中心",
                 "cc_id": "150102-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150102",
                 "cc_x": 558924.7057029144,
                 "cc_y": 4528225.661564901,
                 "cc_lxr": "徐建刚",
                 "cc_city": "新城区",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13948122508",
                 "cc_address": "呼市新城区呼哈公路3.5公里处",
                 
            //  }, {
            //      "cc_name": "配送点2",
            //      "cc_id": "150102-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150102",
            //      "cc_x": 563690.5683759408,
            //      "cc_y": 4529955.735000999,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "新城区",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
            //  {
            //      "cc_name": "配送点3",
            //      "cc_id": "150104-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150104",
            //      "cc_x": 570782.2373191939,
            //      "cc_y": 4537359.959664076,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "玉泉区",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
             }, {
                 "cc_name": "土左旗琦瑜商贸有限公司",
                 "cc_id": "150121-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150121",
                 "cc_x": 514855.16528018046,
                 "cc_y": 4505624.129088736,
                 "cc_lxr": "贾建军",
                 "cc_city": "土默特左旗",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13314718555",
                 "cc_address": "土左旗政府街城建办公楼",
                 
             }, {
                 "cc_name": "土左旗瓦窑粮店有限责任公司",
                 "cc_id": "150121-2",
                 "cc_postalcode": "",
                 "cc_citycode": "150121",
                 "cc_x": 538646.9393160382,
                 "cc_y": 4511907.478344039,
                 "cc_lxr": "王平刚",
                 "cc_city": "土默特左旗",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "8112191",
                 "cc_address": "土左旗中山路",
                 
             },
             {
                 "cc_name": "内蒙古康喜源粮油储运有限公司",
                 "cc_id": "150103-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150103",
                 "cc_x": 549190.5944077333,
                 "cc_y": 4523335.755890795,
                 "cc_lxr": "李镇英",
                 "cc_city": "回民区",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13327101018",
                 "cc_address": "呼和浩特市回民区巴彦淖尔北路2号",
                 
             },
             {
                 "cc_name": "内蒙古呼和浩特西郊国家粮食储备库",
                 "cc_id": "150103-2",
                 "cc_postalcode": "",
                 "cc_citycode": "150103",
                 "cc_x": 551023.4929631471,
                 "cc_y": 4518338.53669931,
                 "cc_lxr": "郑怀诚",
                 "cc_city": "回民区",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "0471-3996199",
                 "cc_address": "呼和浩特市回民区巴彦淖尔北路2号",
                 
             },
             {
                 "cc_name": "托县亿丰粮油有限公司",
                 "cc_id": "150122-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150122",
                 "cc_x": 526970.5757671236,
                 "cc_y": 4467123.058520351,
                 "cc_lxr": "雷钧",
                 "cc_city": "托克托县",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13500694150",
                 "cc_address": "托县双河镇双河北路姜家营",
                 
             },
             {
                 "cc_name": "内蒙古正隆谷物食品有限公司",
                 "cc_id": "150122-2",
                 "cc_postalcode": "",
                 "cc_citycode": "150122",
                 "cc_x": 529493.871552226,
                 "cc_y": 4486209.35923897,
                 "cc_lxr": "贾文良",
                 "cc_city": "托克托县",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "15804719253",
                 "cc_address": "托县托电工业园区",
                 
             },
             {
                 "cc_name": "内蒙古蒙清农业开发有限责任公司",
                 "cc_id": "150124-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150124",
                 "cc_x": 559551.4492873123,
                 "cc_y": 4418428.0198731795,
                 "cc_lxr": "刘三堂",
                 "cc_city": "清水河县",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13848109285",
                 "cc_address": "清水河县宏河镇高茂泉窑",
                 
             },
            //  {
            //      "cc_name": "配送点11",
            //      "cc_id": "150124-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150124",
            //      "cc_x": 554674.6007712155,
            //      "cc_y": 4419296.320880731,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "清水河县",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
             {
                 "cc_name": "内蒙古腾池现代物流有限公司",
                 "cc_id": "150123-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150123",
                 "cc_x": 570062.4614839868,
                 "cc_y": 4470891.680750494,
                 "cc_lxr": "李瑞恒",
                 "cc_city": "和林格尔县",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13948612209",
                 "cc_address": "内蒙古自治区呼和浩特市和林格尔县盛乐经济园区九强公司院内",
                 
             },
            //  {
            //      "cc_name": "配送点13",
            //      "cc_id": "150123-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150123",
            //      "cc_x": 565518.5704971014,
            //      "cc_y": 4468195.377621782,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "和林格尔县",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
            //  {
            //      "cc_name": "配送点14",
            //      "cc_id": "150123-3",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150123",
            //      "cc_x": 566830.8148769347,
            //      "cc_y": 4483217.63791032,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "和林格尔县",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
            //  {
            //      "cc_name": "配送点15",
            //      "cc_id": "150104-1",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150104",
            //      "cc_x": 554844.3438253234,
            //      "cc_y": 4508233.520509456,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "玉泉区",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
             {
                 "cc_name": "内蒙古九州通医疗有限公司",
                 "cc_id": "150105-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150105",
                 "cc_x": 581774.7322174241,
                 "cc_y": 4510676.841201757,
                 "cc_lxr": "田超华",
                 "cc_city": "赛罕区",
                 "cc_landline": "0471-6656999",
                 "cc_mobilephone": "0471-6656999",
                 "cc_address": "呼市赛罕区金桥技术开发区达尔登北路22号",
                 
             },
            //  {
            //      "cc_name": "配送点17",
            //      "cc_id": "150105-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150105",
            //      "cc_x": 582610.3903299546,
            //      "cc_y": 4513085.886854287,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "赛罕区",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
            //  {
            //      "cc_name": "配送点18",
            //      "cc_id": "150105-3",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150105",
            //      "cc_x": 576437.6188815349,
            //      "cc_y": 4519557.340792146,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "赛罕区",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  },
             {
                 "cc_name": "呼和浩特市第六粮库",
                 "cc_id": "150125-1",
                 "cc_postalcode": "",
                 "cc_citycode": "150125",
                 "cc_x": 536610.0226667448,
                 "cc_y": 4549002.8642455945,
                 "cc_lxr": "王喜林",
                 "cc_city": "武川县",
                 "cc_landline": "0471-8888888",
                 "cc_mobilephone": "13704712567",
                 "cc_address": "武川县青山路15号",
                 
             },
            //  {
            //      "cc_name": "配送点20",
            //      "cc_id": "150125-2",
            //      "cc_postalcode": "",
            //      "cc_citycode": "150125",
            //      "cc_x": 513215.67587776436,
            //      "cc_y": 4538601.6137834275,
            //      "cc_lxr": "仓储联系人",
            //      "cc_city": "武川县",
            //      "cc_landline": "0471-8888888",
            //      "cc_mobilephone": "13333333333",
            //      "cc_address": "",
                 
            //  }
         ],
         "field": [],
         "rk_cd": [],
         "rk_cd1": [
             {
                 "rk_cc_id": "150102-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "3"
             },
             {
                 "rk_cc_id": "150102-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "110",
                 "rk_curstock": "120"
             },
             {
                 "rk_cc_id": "150103-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "3"
             },
             {
                 "rk_cc_id": "150103-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "3"
             },
             {
                 "rk_cc_id": "150104-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150104-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150105-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150105-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150121-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150121-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150122-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150122-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150123-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150123-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150124-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150124-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150125-1",
                 "rk_cd_id": "01",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             },
             {
                 "rk_cc_id": "150125-1",
                 "rk_cd_id": "02",
                 "rk_date": "2018-01-01",
                 "rk_number": "5",
                 "rk_curstock": "2"
             }
         ],
         "ck_cd": [],
         "cd_cd_rk": [{
             "cd_id": "0101",
             "cd_name": "大米",
             "cd_type": "粮食",
             "cd_unit": "吨",
             "cd_number": "2000",
             "cd_manufacturer": "",
             "cd_minstock": 8,
             "cd_maxstock": 5,
             "cd_rk_date": (new Date("2017-12-25")).getTime()
         },
         {
             "cd_id": "0102",
             "cd_name": "食用油",
             "cd_type": "油",
             "cd_unit": "吨",
             "cd_number": "2100",
             "cd_manufacturer": "",
             "cd_minstock": 8,
             "cd_maxstock": 5,
             "cd_rk_date": (new Date("2017-12-25")).getTime()
         },
         {
             "cd_id": "0103",
             "cd_name": "其他",
             "cd_type": "其他",
             "cd_unit": "吨",
             "cd_number": "2100",
             "cd_manufacturer": "",
             "cd_minstock": 8,
             "cd_maxstock": 5,
             "cd_rk_date": (new Date("2017-12-25")).getTime()
         },
        //  {
        //      "cd_id": "0104",
        //      "cd_name": "玉米",
        //      "cd_type": "粮食",
        //      "cd_unit": "吨",
        //      "cd_number": "2200",
        //      "cd_manufacturer": "",
        //      "cd_minstock": 8,
        //      "cd_maxstock": 5,
        //      "cd_rk_date": (new Date("2017-12-25")).getTime()
        //  },
         {
             "cd_id": "0105",
             "cd_name": "面粉",
             "cd_type": "粮食",
             "cd_unit": "吨",
             "cd_number": "2200",
             "cd_manufacturer": "",
             "cd_minstock": 8,
             "cd_maxstock": 5,
             "cd_rk_date": (new Date("2017-12-25")).getTime()
         }],
         "cd_cd_ck": [],
         "cd_data": [
             {
                 "cd_id": "0101",
                 "cd_name": "大米",
                 "cd_type": "粮食",
                 "cd_unit": "吨",
                 "cd_number": "139",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2
             },
             {
                 "cd_id": "0102",
                 "cd_name": "食用油",
                 "cd_type": "油",
                 "cd_unit": "吨",
                 "cd_number": "41.2",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2
             },
             {
                 "cd_id": "0103",
                 "cd_name": "其他",
                 "cd_type": "油",
                 "cd_unit": "吨",
                 "cd_number": "1.6",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2
             },
            //  {
            //      "cd_id": "0104",
            //      "cd_name": "玉米",
            //      "cd_type": "粮食",
            //      "cd_unit": "袋",
            //      "cd_number": "20",
            //      "cd_manufacturer": "",
            //      "cd_minstock": 5,
            //      "cd_maxstock": 2
            //  },
             {
                 "cd_id": "0105",
                 "cd_name": "面粉",
                 "cd_type": "粮食",
                 "cd_unit": "吨",
                 "cd_number": "170",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2
             }
         ]
     }
     var map = '', map2 = '', tempVectorLayer = null, options = '', vectorLayer2 ='';
     var oe = '', vectorLayer10 = '';
     var track1 = [],track2 = [];
     $.getJSON('js/gj1.json', function (relust) {
         _.map(relust.features, 'geometry').forEach(element => {
             track1.push([element.x, element.y]);
         });
     });
     $.getJSON('js/gj2.json', function (relust) {
         _.map(relust.features, 'geometry').forEach(element => {
             track2.push([element.x, element.y]);
         });
     });
     var config = {
         webUrl: 'http://192.168.0.24:8060',
         mapUrl: 'http://192.168.0.16:8888'
     }
     if (document.cookie == '') {
         alert('用户未登录，请先登陆!');
         location.href = 'http://localhost/cangchu1/login';
     }
 	echarts_1();
 	// echarts_2();
 	// echarts_3();
    // echarts_4();
    data_1();
    data_2();
    data_3();
    data_4();
    map_1();
    map_2();
    data_tj();
     data_6();
     animation();
     multiplePoint1();
    //  multiplePoint2();
     overlay1();
     inquire();
     function inquire(){
         $('.spxx').hide();
         $('.psdxx').show();
         
         $('.gywd').click(function(){
             $(this).addClass('active5').siblings().removeClass('active5');
             $('#dataTable2 thead').html('<tr><td rowspan="2">序号</td><td rowspan="2">企业名称</td><td rowspan="2">企业组织机构代码</td><td rowspan="2">所在区域</td><td rowspan="2">地址</td><td rowspan="2">企业性质</td><td colspan="3">应急级别</td><td rowspan="2">负责人</td><td rowspan="2">联系电话</td><td colspan="4">日供应能力（吨）</td></tr>'
                 + '<tr><td>省级</td><td>市级</td><td>县级</td><td>面粉</td><td>大米</td><td>食用油</td><td>其他</td></tr>')

             $.ajax({
                 type: "POST",
                 url: config.webUrl + "/FoodSupply/getfoodsupply",
                 data: {
                     tbtime: '2017'
                 },

                 dataType: "json",
                 success: function (relust) {
                     var gywdHtml = '';
                     var gywddata = relust.data
                     for (let i = 0; i < gywddata.length; i++) {
                         gywdHtml += '<tr><td>' + (i + 1) + '</td><td>' + gywddata[i].qymc + '</td><td>' + gywddata[i].qyzzjgdm + '</td><td>' + gywddata[i].szqy + '</td><td>' + gywddata[i].dz + '</td><td>' + gywddata[i].qyxz + '</td><td>' + (gywddata[i].yjjbsj == null ? '' : gywddata[i].yjjbsj) + '</td><td>' + (gywddata[i].yjjbcity == null ? '' : gywddata[i].yjjbcity) + '</td><td>' + (gywddata[i].yjjbxj == null ? '' : gywddata[i].yjjbxj) + '</td><td>' + gywddata[i].dwfzr + '</td><td>' + gywddata[i].lxdh + '</td><td>' + (gywddata[i].rgynlmf == null ? '' : gywddata[i].rgynlmf) + '</td><td>' + (gywddata[i].rgynldm == null ? '' : gywddata[i].rgynldm) + '</td><td>' + (gywddata[i].rgynlsyy == null ? '' : gywddata[i].rgynlsyy) + '</td><td>' + (gywddata[i].rgynlqt == null ? '' : gywddata[i].rgynlqt) + '</td></tr>'
                     }
                     $('#dataTable2 tbody').html(gywdHtml);
                     
                },
                 error: function () {
                     alert('errar');
                 }
             });
         });
         $('.gywd').click();
         $('.pszx').click(function(){
             $(this).addClass('active5').siblings().removeClass('active5');
             $('#dataTable2 thead').html('<tr><td rowspan="2">序号</td><td rowspan="2">企业名称</td><td rowspan="2">企业组织机构代码</td><td rowspan="2">所在区域</td><td rowspan="2">地址</td><td rowspan="2">企业性质</td><td colspan="3">应急级别</td><td rowspan="2">负责人</td><td rowspan="2">联系电话</td><td rowspan="2">仓储能力（吨）</td><td colspan="3">物配送能力</td><td colspan="2">物流能力</td></tr>'
                 + '<tr><td>省级</td><td>市级</td><td>县级</td><td>日配送能力（吨）</td><td>辐射旗县数</td><td>辐射供应网点数量（个）</td><td>日运输能力（吨）</td><td>运输车辆数量(个)</td></tr>')

             $.ajax({
                 type: "POST",
                 url: config.webUrl + "/FoodDistribution/getfooddistribution",
                 data: {
                     tbtime: '2017'
                 },

                 dataType: "json",
                 success: function (relust) {
                     var gywdHtml = '';
                     var pszxdata = relust.data
                     for (let i = 0; i < pszxdata.length; i++) {
                         gywdHtml += '<tr><td>' + (i + 1) + '</td><td>' + pszxdata[i].qymc + '</td><td>' + pszxdata[i].qyzzjgdm + '</td><td>' + pszxdata[i].szqy + '</td><td>' + pszxdata[i].dz + '</td><td>' + pszxdata[i].qyxz + '</td><td>' + (pszxdata[i].yjjbsj == null ? '' : pszxdata[i].yjjbsj) + '</td><td>' + (pszxdata[i].yjjbcity == null ? '' : pszxdata[i].yjjbcity) + '</td><td>' + (pszxdata[i].yjjbxj == null ? '' : pszxdata[i].yjjbxj) + '</td><td>' + (pszxdata[i].dwfzr) + '</td><td>' + (pszxdata[i].lxdh) + '</td><td>' + (pszxdata[i].ccnl == null ? '' : pszxdata[i].ccnl) + '</td><td>' + (pszxdata[i].psnlrpsnl == null ? '' : pszxdata[i].psnlrpsnl) + '</td><td>' + (pszxdata[i].psnlfsqxs == null ? '' : pszxdata[i].psnlfsqxs) + '</td><td>' + (pszxdata[i].psnlfsgywd == null ? '' : pszxdata[i].psnlfsgywd) + '</td><td>' + (pszxdata[i].wlnlrysnl == null ? '' : pszxdata[i].wlnlrysnl) + '</td><td>' + (pszxdata[i].wlnlysclsl == null ? '' : pszxdata[i].wlnlysclsl) + '</td></tr>'
                     }
                     $('#dataTable2 tbody').html(gywdHtml);
             },
                 error: function () {
                     alert('errar');
                 }
             });
        });
         $('.jgqy').click(function(){
             $(this).addClass('active5').siblings().removeClass('active5');
             $('#dataTable2 thead').html('<tr><td rowspan="2">序号</td><td rowspan="2">企业名称</td><td rowspan="2">企业组织机构代码</td><td rowspan="2">所在区域</td><td rowspan="2">地址</td><td rowspan="2">企业性质</td><td colspan="3">应急级别</td><td rowspan="2">负责人</td><td rowspan="2">联系电话</td><td colspan="5">日加工能力（吨）</td></tr>'
                 + '<tr><td>省级</td><td>市级</td><td>县级</td><td>小麦</td><td>稻谷</td><td>油料处理</td><td>油脂精炼</td><td>其他</td></tr>')

               $.ajax({
                 type: "POST",
                 url: config.webUrl + "/FoodMachining/getfoodmachining",
                 data: {
                     tbtime: '2017'
                 },

                 dataType: "json",
                 success: function (relust) {
                     var gywdHtml = '';
                     var jgqydata = relust.data
                     for (let i = 0; i < jgqydata.length; i++) {
                         gywdHtml += '<tr><td>' + (i + 1) + '</td><td>' + jgqydata[i].qymc + '</td><td>' + jgqydata[i].qyzzjgdm + '</td><td>' + jgqydata[i].szqy + '</td><td>' + jgqydata[i].dz + '</td><td>' + jgqydata[i].qyxz + '</td><td>' + (jgqydata[i].yjjbsj == null ? '' : jgqydata[i].yjjbsj) + '</td><td>' + (jgqydata[i].yjjbcity == null ? '' : jgqydata[i].yjjbcity) + '</td><td>' + (jgqydata[i].yjjbxj == null ? '' : jgqydata[i].yjjbxj) + '</td><td>' + (jgqydata[i].dwfzr == null ? '' : jgqydata[i].dwfzr) + '</td><td>' + (jgqydata[i].lxdh == null ? '' : jgqydata[i].lxdh) + '</td><td>' + (jgqydata[i].rjgnlxm == null ? '' : jgqydata[i].rjgnlxm) + '</td><td>' + (jgqydata[i].rjgnldg == null ? '' : jgqydata[i].rjgnldg) + '</td><td>' + (jgqydata[i].rjgnlylcl == null ? '' : jgqydata[i].rjgnlylcl) + '</td><td>' + (jgqydata[i].rjgnlyzjl == null ? '' : jgqydata[i].rjgnlyzjl) + '</td><td>' + (jgqydata[i].rjgnlqt == null ? '' : jgqydata[i].rjgnlqt) + '</td></tr>'
                     }
                     $('#dataTable2 tbody').html(gywdHtml);
             },
                 error: function () {
                     alert('errar');
                 }
             });
        });
         $('.cyqy').click(function(){
             $(this).addClass('active5').siblings().removeClass('active5');
             $('#dataTable2 thead').html('<tr><td rowspan="2">序号</td><td rowspan="2">企业名称</td><td rowspan="2">企业组织机构代码</td><td rowspan="2">所在区域</td><td rowspan="2">地址</td><td rowspan="2">企业性质</td><td colspan="3">应急级别</td><td rowspan="2">负责人</td><td rowspan="2">联系电话</td><td rowspan="2">仓储能力（吨）</td><td colspan="2">物流能力</td></tr>'
                 + '<tr><td>省级</td><td>市级</td><td>县级</td><td>日运输能力（吨）</td><td>运输车辆数量(个)</td></tr>')

               $.ajax({
                 type: "POST",
                 url: config.webUrl + "/FoodStore/getfoodftore",
                 data: {
                     tbtime: '2017'
                 },

                 dataType: "json",
                 success: function (relust) {
                     var gywdHtml = '';
                     var cyqydata = relust.data
                     for (let i = 0; i < cyqydata.length; i++) {
                         gywdHtml += '<tr><td>' + (i + 1) + '</td><td>' + cyqydata[i].qymc + '</td><td>' + cyqydata[i].qyzzjgdm + '</td><td>' + cyqydata[i].szqy + '</td><td>' + cyqydata[i].dz + '</td><td>' + cyqydata[i].qyxz + '</td><td>' + (cyqydata[i].yjjbsj == null ? '' : cyqydata[i].yjjbsj) + '</td><td>' + (cyqydata[i].yjjbcity == null ? '' : cyqydata[i].yjjbcity) + '</td><td>' + (cyqydata[i].yjjbxj == null ? '' : cyqydata[i].yjjbxj) + '</td><td>' + (cyqydata[i].dwfzr) + '</td><td>' + (cyqydata[i].lxdh) + '</td><td>' + (cyqydata[i].ccnl == null ? '' : cyqydata[i].ccnl) + '</td><td>' + (cyqydata[i].wlnlrysnl == null ? '' : cyqydata[i].wlnlrysnl) + '</td><td>' + (cyqydata[i].wlnlysclsl == null ? '' : cyqydata[i].wlnlysclsl) + '</td></tr>'
                     }
                     $('#dataTable2 tbody').html(gywdHtml);
             },
                 error: function () {
                     alert('errar');
                 }
             });
         });
     }
     function data_6() {
        //  $('#popup-closer').click(function () {
        //      alert(123);
        //  })
         $(".slMap").click(function () {
             console.log(123);
            //  $('#popup').hide();
            map.getLayers().forEach(function (layer) {
                if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer1') {
                     layer.setVisible(true);
                 }
                if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer2') {
                     layer.setVisible(false);
                 }
                if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer5'){
                   layer.setVisible(false);
               }
             });
             console.log('/*/*/*/778787878', map.getOverlayById('overlayClose'));
             map.getOverlayById('overlayClose').setPosition(undefined);
             
            //  map.getOverlays().setPosition(undefined)
            //  ;
             oe = new ADLayer(options, map, echarts)
              oe.render()
         });
         $(".yxMap").click(function () {
            //  indexs = 1;
             oe.clear();
             map.getLayers().forEach(function (layer) {
                 if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer2') {
                     layer.setVisible(true);
                 }
                 if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer1') {
                     layer.setVisible(false);
                 }
                //  if (layer.getProperties().name != 'base_Layer1' && layer.getProperties().name != 'base_Layer2') {
                //      layer.setVisible(true);
                //  }
             });
         });
         var cd_ID = _.map(data.cd_data, 'cd_id');
         var year = 2018, month = 0;

         for (i = 0; i < 16; i++) {
             var date = _.join([year, ++month, 25], '-');
             if (i > 0 && i % 12 == 0) {
                 month = 0;
                 ++year;
             }
             // data.cd_data.forEach(element => {
             var data_cd1 = {
                 "cd_id": "0101",
                 "cd_name": "大米",
                 "cd_type": "粮食",
                 "cd_unit": "吨",
                 "cd_number": "200",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2,
                 "cd_rk_date": (new Date(date)).getTime()
             }
             var data_cd2 = {
                 "cd_id": "0102",
                 "cd_name": "食用油",
                 "cd_type": "油",
                 "cd_unit": "吨",
                 "cd_number": "210",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2,
                 "cd_rk_date": (new Date(date)).getTime()
             }
             var data_cd3 = {
                 "cd_id": "0103",
                 "cd_name": "其他",
                 "cd_type": "油",
                 "cd_unit": "吨",
                 "cd_number": "210",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2,
                 "cd_rk_date": (new Date(date)).getTime()
             }
             var data_cd4 = {
                 "cd_id": "0104",
                 "cd_name": "玉米",
                 "cd_type": "粮食",
                 "cd_unit": "吨",
                 "cd_number": "220",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2,
                 "cd_rk_date": (new Date(date)).getTime()
             }
             var data_cd5 = {
                 "cd_id": "0105",
                 "cd_name": "面粉",
                 "cd_type": "粮食",
                 "cd_unit": "吨",
                 "cd_number": "220",
                 "cd_manufacturer": "",
                 "cd_minstock": 5,
                 "cd_maxstock": 2,
                 "cd_rk_date": (new Date(date)).getTime()
             };
             data.cd_cd_rk.push(data_cd1);
             data.cd_cd_rk.push(data_cd2);
             data.cd_cd_rk.push(data_cd3);
            //  data.cd_cd_rk.push(data_cd4);
             data.cd_cd_rk.push(data_cd5);
             data.cd_cd_ck.push(data_cd1);
             data.cd_cd_ck.push(data_cd2);
             data.cd_cd_ck.push(data_cd3);
            //  data.cd_cd_ck.push(data_cd4);
             data.cd_cd_ck.push(data_cd5);
             // });

         }
     }
     function map_1() {
        //  layer.setVisible(true);

        //  var bounds = [327973.140955358, 4359309.63308147, 755830.094571045, 4603992.86874643];
        //  var resolutions = [1671.3162250612775, 835.6581125306387, 417.82905626531937, 208.91452813265968, 104.45726406632984, 52.22863203316492, 26.11431601658246, 13.05715800829123, 6.528579004145615, 3.2642895020728075, 1.6321447510364038,
        //      0.8160723755182019, 0.40803618775910094, 0.20401809387955047, 0.10200904693977524, 0.05100452346988762, 0.02550226173494381];
         var bounds = [-170902.133172, 3775487.425615, 1037208.330403, 4839529.097046];
         var resolutions = [2359.5907491699218, 1179.7953745849609, 589.8976872924804, 294.9488436462402, 147.4744218231201, 73.73721091156006, 36.86860545578003, 18.434302727890014,
             9.217151363945007, 4.6085756819725034, 2.3042878409862517, 1.1521439204931259, 0.5760719602465629, 0.28803598012328147, 0.14401799006164073, 0.07200899503082037]; 
        var matrixIds = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
         proj4.defs('EPSG:32649', '+proj=utm +zone=49 +datum=WGS84 +units=m +no_defs');
         var projection = ol.proj.get('EPSG:32649');
         //var mapUri = 'http://192.168.0.16:8888/cgi-bin/mapserv.exe?MAP=E:/ms4w/apps/hsmap/hsmapUTM-baidu.map';
         //var mapUri = 'http://127.0.0.1:88/hsmap?';
         var mapUri = config.mapUrl + '/hsmap?';
         let wmsSource = new ol.source.ImageWMS({
             url: mapUri,
             params: {
                 'FORMAT': 'image/png',
                 'VERSION': '1.1.1',
                 'WIDTH': 256,
                 'HEIGHT': 256,
                 'SRS': 'EPSG:32649',
                 'LAYERS': 'ctiy,ctiy2,water,tl,xl,yl,sl,gl,countyp,ctiyp,government,hospital' //,80Worklimitlgsj1,nmjs,qxj,msm,qxm,sxm,sxx,tl,sjysgl,mzfzd,zrc'
             },
             serverType: 'mapserver',
             crossOrigin: 'anonymous'
         });
         var wmsLayer = new ol.layer.Image({
             name: 'base_Layer1',
             source: wmsSource
         });
         var mapUris = config.mapUrl + '/mapcache/wmts/';
         var projections = ol.proj.get('EPSG:32649');
         var tileGrid = new ol.tilegrid.WMTS({
             origin: [bounds[0], bounds[3]],
             resolutions: resolutions,
             matrixIds: matrixIds,
             sizes: [256, 256],
             extent: bounds
         });
         var wmtsSource = new ol.source.WMTS({
             url: mapUris,
             layer: 'hs-map',
             format: 'image/png',
             matrixSet: 'Utm49N',
             projection: projections,
             tileGrid: tileGrid
         });
         var wmsImgLayer = new ol.layer.Tile({
             name: 'base_Layer2',
             source: wmtsSource
         });
         
         wmsImgLayer.setVisible(false);
         wmsLayer.setVisible(true);
         
         //
         var view = new ol.View({
             center: [536364.4721706877, 4483724.758172186],//地图中心位置
             projection: projection,
             extent: bounds,
             minResolution: resolutions[2],
             resolutions: resolutions,
            //  resolution: resolutions[2]//地图初始层级
            zoom:2.5

         })
         //创建地图
         map = new ol.Map({
             view: view,
             layers: [wmsLayer, wmsImgLayer],
             target: 'map'
         });
         console.log('/*/*/*/*//*//*/*',map);
         
        //  if (index != 1) {
            //  echartsMap();
        //  }
        //  function echartsMap() {


             var geoCoordMap = {
                 '中心': [553013.216027, 4519649.39635],
                 '呼和浩特市军粮供应服务中心': [558924.7057029144, 4528225.661564901],
                //  '配送点2': [563690.5683759408, 4529955.735000999],
                //  '配送点3': [570782.2373191939, 4537359.959664076],
                 '土左旗琦瑜商贸有限公司': [514855.1652801804, 4505624.129088736],
                 '土左旗瓦窑粮店有限责任公司': [538646.9393160382, 4511907.478344039],
                 '内蒙古康喜源粮油储运有限公司': [549190.5944077333, 4523335.755890795],
                 '内蒙古呼和浩特西郊国家粮食储备库': [551023.4929631471, 4518338.53669931],
                 '托县亿丰粮油有限公司': [526970.5757671236, 4467123.058520351],
                 '内蒙古正隆谷物食品有限公司': [529493.871552226, 4486209.35923897],
                 '内蒙古蒙清农业开发有限责任公司': [559551.4492873123, 4418428.0198731795],
                //  '配送点11': [554674.6007712155, 4419296.320880731],
                 '内蒙古腾池现代物流有限公司': [570062.4614839868, 4470891.680750494],
                //  '配送点13': [565518.5704971014, 4468195.377621782],
                //  '配送点14': [566830.8148769347, 4483217.63791032],
                //  '配送点15': [554844.3438253234, 4508233.520509456],
                 '内蒙古九州通医疗有限公司': [581774.7322174241, 4510676.841201757],
                //  '配送点17': [582610.3903299546, 4513085.886854287],
                //  '配送点18': [576437.6188815349, 4519557.340792146],
                 '呼和浩特市第六粮库': [536610.0226667448, 4549002.864245594],
                //  '配送点20': [513215.6758777643, 4538601.613783427]
             };

             var BJData = [
                 [{ name: '中心' }, { name: '呼和浩特市军粮供应服务中心', value: 100 }],
                //  [{ name: '中心' }, { name: '配送点2', value: 70 }],
                //  [{ name: '中心' }, { name: '配送点3', value: 30 }],
                 [{ name: '中心' }, { name: '土左旗琦瑜商贸有限公司', value: 50 }],
                 [{ name: '中心' }, { name: '土左旗瓦窑粮店有限责任公司', value: 20 }],
                 [{ name: '中心' }, { name: '内蒙古康喜源粮油储运有限公司', value: 10 }],
                 [{ name: '中心' }, { name: '内蒙古呼和浩特西郊国家粮食储备库', value: 80 }],
                 [{ name: '中心' }, { name: '托县亿丰粮油有限公司', value: 55 }],
                 [{ name: '中心' }, { name: '内蒙古正隆谷物食品有限公司', value: 90 }],
                 [{ name: '中心' }, { name: '内蒙古蒙清农业开发有限责任公司', value: 100 }],
                //  [{ name: '中心' }, { name: '配送点11', value: 70 }],
                 [{ name: '中心' }, { name: '内蒙古腾池现代物流有限公司', value: 30 }],
                //  [{ name: '中心' }, { name: '配送点13', value: 50 }],
                //  [{ name: '中心' }, { name: '配送点14', value: 20 }],
                //  [{ name: '中心' }, { name: '配送点15', value: 10 }],
                 [{ name: '中心' }, { name: '内蒙古九州通医疗有限公司', value: 80 }],
                //  [{ name: '中心' }, { name: '配送点17', value: 55 }],
                //  [{ name: '中心' }, { name: '配送点18', value: 90 }],
                 [{ name: '中心' }, { name: '呼和浩特市第六粮库', value: 55 }],
                //  [{ name: '中心' }, { name: '配送点20', value: 90 }]
             ];
             var convertData = function (data) {
                 var res = [];
                 for (var i = 0; i < data.length; i++) {
                     var dataItem = data[i];
                     var fromCoord = geoCoordMap[dataItem[0].name];
                     var toCoord = geoCoordMap[dataItem[1].name];
                     if (fromCoord && toCoord) {
                         res.push([{
                             coord: fromCoord
                         }, {
                             coord: toCoord,
                             value: dataItem[1].value
                         }]);
                     }
                 }
                 return res;
             };
             var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
             var color = ['#a6c84c', '#ffa022', '#46bee9'];
             var series = [];
             [
                 ['中心', BJData]
             ].forEach(function (item, i) {
                 console.log(item[0]);
                 series.push(
                     {
                         type: 'lines',
                         zlevel: 2,
                         effect: {
                             show: true,
                             period: 4,
                             trailLength: 0.02,
                             symbol: 'arrow',
                             //symbol: planePath,
                             symbolSize: 5,
                         },
                         lineStyle: {
                             normal: {
                                 width: 1,
                                 opacity: 0.6,
                                 curveness: 0.2
                             }
                         },

                         data: convertData(item[1])
                     }, {
                         type: 'effectScatter',
                         coordinateSystem: 'geo',
                         zlevel: 2,
                         rippleEffect: {
                             period: 4,
                             brushType: 'stroke',
                             scale: 4
                         },
                         label: {
                             normal: {
                                 show: true,
                                 position: 'right',
                                 offset: [5, 0],
                                 formatter: '{b}'
                             },
                             emphasis: {
                                 show: true
                             }
                         },
                         symbol: 'circle',
                         symbolSize: function (val) {
                             return 4 + val[2] / 10;
                         },
                         itemStyle: {
                             normal: {
                                 show: false,
                                 color: '#f00'
                             }
                         },
                         data: item[1].map(function (dataItem) {
                             return {
                                 name: dataItem[1].name,
                                 value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
                             };
                         }),
                     },
                     //被攻击点
                     {
                         type: 'scatter',
                         coordinateSystem: 'geo',
                         zlevel: 2,
                         rippleEffect: {
                             period: 4,
                             brushType: 'stroke',
                             scale: 4
                         },
                         label: {
                             normal: {
                                 show: true,
                                 //position: 'right',
                                 //			                offset:[5, 0],

                                 color: '#00ffff',
                                 formatter: '{b}',
                                 textStyle: {
                                     color: "#00ffff"
                                 }
                             },
                             emphasis: {
                                 show: true
                             }
                         },
                         symbol: 'pin',
                         symbolSize: 30,
                         itemStyle: {
                             normal: {
                                 show: true,
                                 color: '#f5f5f5'
                             }
                         },
                         data: [{
                             name: item[0],
                             value: geoCoordMap[item[0]].concat([100]),
                         }],
                     }
                 );
             });

             options = {
                 tooltip: {
                     trigger: 'item'
                 },
                 visualMap: {
                     min: 0,
                     max: 100,
                     calculable: true,
                     color: ['#ff3333', 'orange', 'yellow', 'lime', 'aqua'],
                     textStyle: {
                         color: '#fff'
                     }
                 },
                 series: series
             };

             oe = new ADLayer(options, map, echarts)
             oe.render()
             //setTimeout(()=>{oe.clear()},2000)
        //  }
         
         
     }
     function map_2(){
         $(function(){

         
         var bounds = [-170902.133172, 3775487.425615, 1037208.330403, 4839529.097046];
         var resolutions = [2359.5907491699218, 1179.7953745849609, 589.8976872924804, 294.9488436462402, 147.4744218231201, 73.73721091156006, 36.86860545578003, 18.434302727890014,
             9.217151363945007, 4.6085756819725034, 2.3042878409862517, 1.1521439204931259, 0.5760719602465629, 0.28803598012328147, 0.14401799006164073, 0.07200899503082037];
         var matrixIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
         var mapUris = config.mapUrl + '/mapcache/wmts/';
         var projection = ol.proj.get('EPSG:32649');
         var tileGrid = new ol.tilegrid.WMTS({
             origin: [bounds[0], bounds[3]],
             resolutions: resolutions,
             matrixIds: matrixIds,
             sizes: [256, 256],
             extent: bounds
         });
         var wmtsSources = new ol.source.WMTS({
             url: mapUris,
             layer: 'hs-map',
             format: 'image/png',
             matrixSet: 'Utm49N',
             projection: projection,
             tileGrid: tileGrid
         });
         var wmsImgLayers = new ol.layer.Tile({
             name: 'base_Layer3',
             source: wmtsSources
         });
         var view = new ol.View({
             center: [536364.4721706877, 4483724.758172186],//地图中心位置
             projection: projection,
             extent: bounds,
             minResolution: resolutions[3],
             resolutions: resolutions,
             resolution: resolutions[3]//地图初始层级

         })
         //创建地图
         map2 = new ol.Map({
             view: view,
             layers: [wmsImgLayers],
            //  target: 'aaa'
         });
         
         })
     }

     function multiplePoint1() {
         
        //  map.removeLayer(tempVectorLayer);
        var vectorSource = new ol.source.Vector({
                 features: []
             });
             var iconStyle = new ol.style.Style({
                 image: new ol.style.Circle({
                     radius: 7,
                     fill: new ol.style.Fill({
                         color: 'yellow'
                     })
                 })
             });
        vectorLayer2 = new ol.layer.Vector({
            name: "base_Layer2",
            source: vectorSource,
            style: iconStyle
        });

        map.getLayers().push(vectorLayer2);
        //  map2.getLayers().push(vectorLayer2);
        // console.log('-----------*-********',map.getLayers());
        //  vectorLayer2.setVisible(false);
        data.storageData.forEach(element => {
            var feature = new ol.Feature({
                geometry: new ol.geom.Point([element.cc_x, element.cc_y]),
            });
            // feature.setStyle(iconStyle);
            feature.flatCoordinates_ = [element.cc_x, element.cc_y];
            feature.setProperties(element);
            vectorSource.addFeature(feature);
        });
     }
     function multiplePoint2() {

         //  map.removeLayer(tempVectorLayer);
         var vectorSource = new ol.source.Vector({
             features: []
         });
         var iconStyle = new ol.style.Style({
             image: new ol.style.Circle({
                 radius: 7,
                 fill: new ol.style.Fill({
                     color: 'yellow'
                 })
             })
         });
         var vectorLayer = new ol.layer.Vector({
             name: "base_Layer6",
             source: vectorSource,
             style: iconStyle
         });

         map2.getLayers().push(vectorLayer);
         //  map2.getLayers().push(vectorLayer2);
         // console.log('-----------*-********',map.getLayers());
         //  vectorLayer2.setVisible(false);
         data.storageData.forEach(element => {
             var feature = new ol.Feature({
                 geometry: new ol.geom.Point([element.cc_x, element.cc_y]),
             });
             // feature.setStyle(iconStyle);
             feature.flatCoordinates_ = [element.cc_x, element.cc_y];
             feature.setProperties(element);
             vectorSource.addFeature(feature);
         });
     }
     function overlay1() {
         map.on("singleclick", clickMapHandle);

         var container = document.getElementById('popup');
         var content = document.getElementById('popup-content');
         var closer = document.getElementById('popup-closer');
         var overlay = new ol.Overlay({
             element: container,
             id: "overlayClose",
             autoPan: true,
             autoPanAnimation: {
                 duration: 250
             }
         });
         map.addOverlay(overlay);
         closer.onclick = function () {
             overlay.setPosition(undefined);
             closer.blur();
              return false;
         };
         function clickMapHandle(event) {
             var pixel = map.getEventPixel(event.originalEvent);
             map.forEachFeatureAtPixel(pixel, function (feature, layer) {
                 if (feature != undefined) {
                     var featureData = feature.getProperties();
                     console.log('/*/*/*/*/*/*//*', feature.getProperties());
                     content.innerHTML = '<div><span>仓储名称：</span><span>' + featureData.cc_name+'</span></div>'
                         + '<div><span>仓储联系人：</span><span>' + featureData.cc_lxr+'</span></div>'
                         + '<div><span>所在城市：</span><span>' + featureData.cc_city+'</span></div>'
                         + '<div><span>行政编码：</span><span>' + featureData.cc_citycode+'</span></div>'
                         + '<div><span>仓储地址：</span><span>' + featureData.cc_address+'</span></div>'
                         + '<div><span>邮政编码：</span><span>' + featureData.cc_postalcode+'</span></div>'
                        //  + '<div><span>联系电话座机：</span><span>' + featureData.cc_landline+'</span></div>'
                         + '<div><span>联系电话：</span><span>' + featureData.cc_mobilephone+'</span></div>'
                     overlay.setPosition([featureData.cc_x, featureData.cc_y]);
                 }
             })
         }
     }
    function addPoint(jd, wd){
         var feature = new ol.Feature({
             geometry: new ol.geom.Point([jd, wd]),
         });
         feature.flatCoordinates_ = [jd, wd];
        var tempVectorSource = new ol.source.Vector({
             features: [feature]
         });
         var tempIconStyle = new ol.style.Style({
             image: new ol.style.Circle({
                 radius: 6,
                 fill: new ol.style.Fill({
                     color: 'red'
                 })
             })
         });
         if (tempVectorLayer == null) {
             tempVectorLayer = new ol.layer.Vector({
                 source: tempVectorSource,
                 style: tempIconStyle
             });
             map2.getLayers().push(tempVectorLayer);
         } else {
             tempVectorLayer.setSource(tempVectorSource);
         }
     }

    function data_1(){
        var cc_ID = _.map(data.storageData,'cc_id');
        var cd_ID = _.map(data.cd_data, 'cd_id');
        
        for (let i = 0; i < cc_ID.length; i++) {
            var ck_cd_id = _.sampleSize(cd_ID, _.random(2, cd_ID.length));
            
            ck_cd_id.forEach(element => {
                var year = 2018, month = 0;
                for (let j = 0; j < 17; j++) {
                    if (j > 0 && j % 12 == 0) {
                        month = 0;
                        ++year;
                    }
                    var date = [year, ++month, 25].join('-');
                    var rk_number = 5, rk_curstock = 0;
                    var ck_number = _.random((rk_number + rk_curstock)-3, (rk_number + rk_curstock));
                    data.ck_cd.push({
                        "ck_cc_id": cc_ID[i],
                        "ck_cd_id": element,
                        "ck_date": (new Date(date)).getTime(),
                        "ck_number": ck_number
                    });
                    
                    if (year == 2018 && month == 1) {
                        data.rk_cd.push({
                            "rk_cc_id": cc_ID[i],
                            "rk_cd_id": element,
                            "rk_date": (new Date("2017-12-25")).getTime(),
                            "rk_number": rk_number,
                            "rk_curstock": rk_curstock,
                        })
                        rk_curstock = rk_number + rk_curstock - ck_number;
                        rk_number = _.random((ck_number - 1), (ck_number));
                        data.rk_cd.push({
                            "rk_cc_id": cc_ID[i],
                            "rk_cd_id": element,
                            "rk_date": (new Date(date)).getTime(),
                            "rk_number": rk_number,
                            "rk_curstock": rk_curstock,
                        });
                    } else {
                        rk_curstock = rk_number + rk_curstock - ck_number;
                        rk_number = _.random((ck_number - 1), (ck_number));
                        data.rk_cd.push({
                            "rk_cc_id": cc_ID[i],
                            "rk_cd_id": element,
                            "rk_date": (new Date(date)).getTime(),
                            "rk_number": rk_number,
                            "rk_curstock": rk_curstock,
                        });
                    }
                }
            });
        }
        
        
        
        
        $('.tab_right a').click(function(){
            $('.tab_right a').removeClass('active');
            $(this).addClass('active');
        });
        $('.tab_right .cc').click(function(){
            var html_cc = '';
            html_cc += '<thead><tr><th>序号</th><th>名称</th><th>所在地</th></tr></thead><tbody id="cc_id">'
            for (var i = 0; i < data.storageData.length; i++) {
                html_cc += '<tr><input type="hidden" value=' + data.storageData[i].cc_id + ' />'
                    + '<td><span>' + (i + 1) + '</span></td>'
                    + '<td>' + data.storageData[i].cc_name + '</td>'
                    + '<td>' + data.storageData[i].cc_city + '</td>'
                    + '</tr>';
            }
            html_cc += '</tbody>'
            $('.tab_table table').html(html_cc);
            var ccId = data.storageData[0].cc_id;
            function ccid() {
                $('.tab_lb').html('商品最新入库数量');
                var html_cc_cd = '';
                html_cc_cd += '<thead><tr><th>序号</th><th>商品名称</th><th>入库数量</th></tr></thead><tbody id="cdId">'
                var cc_cd_data = _.uniqBy(_.filter(data.rk_cd, { rk_cc_id: ccId }), 'rk_cd_id');
                // var cc_cd_data = _.filter(data.rk_cd, { 'rk_cc_id': ccId,'rk_date': _.maxBy(data.rk_cd,'rk_date').rk_date});
                var cdName = [], cdNumber = [], cdMaxstock = [];
                cc_cd_data.forEach((element,index) => {
                    var cd_max = _.maxBy(_.filter(data.rk_cd, { 'rk_cc_id': ccId, 'rk_cd_id': element.rk_cd_id }),'rk_date');
                    // var cd_max = _.filter(data.rk_cd, { 'rk_cc_id': ccId, 'rk_cd_id': element.rk_cd_id})
                    var cdData = data.cd_data[_.findIndex(data.cd_data, { 'cd_id': element.rk_cd_id })];
                    cdName.push(cdData.cd_name);
                    cdMaxstock.push(cdData.cd_maxstock);
                    cdNumber.push((parseInt(cd_max.rk_curstock) + parseInt(cd_max.rk_number)));
                    html_cc_cd += '<tr><input type="hidden" value=' + cd_max.rk_cd_id +' /><td><span>'+(index + 1)+'</span></td>'
                        + '<td>'+ cdData.cd_name +'</td>'
                        + '<td>' + cd_max.rk_number + '（'+cdData.cd_unit+'）' + '</td></tr>'
                        // + '<td>' +  + '</td>'
                });
                html_cc_cd += '</tbody>';
                $('.cc_cd table').html(html_cc_cd);
                echarts_2(cdName, cdNumber, cdMaxstock);
                
                $('#cdId tr').click(function(){
                    var data1 = _.filter(data.ck_cd, { "ck_cc_id": ccId, "ck_cd_id": $(this).children('input').val()});
                    var data_rk_cd = _.filter(data.rk_cd, { "rk_cc_id": ccId, "rk_cd_id": $(this).children('input').val() })
                    var cdNumberArray = [],cdDateArray = [];//_.map(data1,'ck_date');//_.map(data1,'ck_number')
                    data1.forEach((element,index) => {
                        cdNumberArray.push(element.ck_number);
                        var date9 = new Date(element.ck_date);
                        cdDateArray.push(date9.getFullYear() + "-" + (date9.getMonth() + 1) + "-" + date9.getDate());
                        // cdNumberArray.push(_.round(element.ck_number*100/(data_rk_cd[index].rk_number + data_rk_cd[index].rk_curstock),2));
                    });
                    echarts_4(cdNumberArray, cdDateArray);
                });
                $('#cdId tr').click();
            };
            ccid();
            var tempVectorLayer1 = null;
            $("#cc_id tr").click(function(){
                ccId = $(this).children('input').val();
                $(".yxMap").click();
                ccid();
                var jwd = _.filter(data.storageData, { cc_id: $(this).children('input').val()});
                map.getView().animate({
                    center: [jwd[0].cc_x, jwd[0].cc_y],
                    duration: 0,
                    zoom: 5,
                });
                var feature = new ol.Feature({
                    geometry: new ol.geom.Point([jwd[0].cc_x, jwd[0].cc_y]),
                });
                feature.flatCoordinates_ = [jwd[0].cc_x, jwd[0].cc_y];
                var tempVectorSource = new ol.source.Vector({
                    features: [feature]
                });
                var tempIconStyle = new ol.style.Style({
                    image: new ol.style.Circle({
                        radius: 8,
                        fill: new ol.style.Fill({
                            color: 'red'
                        })
                    })
                });
                if (tempVectorLayer1 == null) {
                    tempVectorLayer1 = new ol.layer.Vector({
                        source: tempVectorSource,
                        style: tempIconStyle
                    });
                    map.getLayers().push(tempVectorLayer1);
                } else {
                    tempVectorLayer1.setSource(tempVectorSource);
                }
            });
        });
        
        $('.tab_right .cd').click(function () {
            var html_cd = '';
            html_cd += '<thead><tr><th>序号</th><th>名称</th></tr></thead><tbody id="cd_id">'
            for (var i = 0; i < data.cd_data.length; i++) {
                html_cd += '<tr><input type="hidden" value=' + data.cd_data[i].cd_id + ' />'
                    + '<td><span>' + (i + 1) + '</span></td>'
                    + '<td>' + data.cd_data[i].cd_name + '</td>'
                    // + '<td>' + data.cd_data[i].cc_city + '</td>'
                    + '</tr>';
            }
            html_cd += '</tbody>'
            $('.tab_table table').html(html_cd);
            $("#cd_id tr").click(function () {
                $('.tab_lb').html('配送点库存');
                var html_cd_cc = '';
                html_cd_cc += '<thead><tr><th>序号</th><th>名称</th><th>库存</th></tr></thead><tbody id="ccId">'
                var cd_cc_data = _.uniqBy(_.filter(data.rk_cd, { rk_cd_id: $(this).children('input').val() }), 'rk_cc_id');
                // var cd_cc_data = _.filter(data.rk_cd, { 'rk_cd_id': $(this).children('input').val(), 'rk_date': _.maxBy(data.rk_cd, 'rk_date').rk_date });
                var ccName = [], ccKc = [];
                var cddata = _.filter(data.cd_data, { 'cd_id': $(this).children('input').val() });
                var maxstock = cddata[0].cd_maxstock, unit = cddata[0].cd_unit;
                cd_cc_data.forEach((element, index) => {
                    var ccData = data.storageData[_.findIndex(data.storageData, { 'cc_id': element.rk_cc_id })];
                    var cc_max = _.maxBy(_.filter(data.rk_cd, { 'rk_cd_id': $(this).children('input').val(), 'rk_cc_id': element.rk_cc_id }), 'rk_date');
                    ccName.push(ccData.cc_name);
                    ccKc.push((cc_max.rk_number + cc_max.rk_curstock));
                    html_cd_cc += '<tr><input type="hidden" value=' + cc_max.rk_cc_id +' /><td><span>' + (index + 1) + '</span></td>'
                        + '<td>' + ccData.cc_name + '</td>'
                        + '<td>' + (cc_max.rk_number + cc_max.rk_curstock) + data.cd_data[_.findIndex(data.cd_data, { 'cd_id': cc_max.rk_cd_id })].cd_unit + '</td></tr>'
                });
                html_cd_cc += '</tbody>';
                $('.cc_cd table').html(html_cd_cc);
                echarts_5(ccName, ccKc, maxstock,unit);
                var cdId = $(this).children('input').val();
                $("#ccId tr").click(function(){
                    var data2 = _.filter(data.ck_cd, { "ck_cc_id": $(this).children('input').val(), "ck_cd_id": cdId });
                    var data_rk_cd2 = _.filter(data.rk_cd, { "rk_cc_id": $(this).children('input').val(), "rk_cd_id": cdId })
                    var cdNumberArray2 = [], cdDateArray2 = [];//_.map(data2, 'ck_date');//_.map(data1,'ck_number')
                    data2.forEach((element, index) => {
                        cdNumberArray2.push(element.ck_number);
                        var date10 = new Date(element.ck_date);
                        cdDateArray2.push(date10.getFullYear() + "-" + (date10.getMonth() + 1) + "-" + date10.getDate());
                        // cdNumberArray2.push(_.round(element.ck_number * 100 / (data_rk_cd2[index].rk_number + data_rk_cd2[index].rk_curstock), 2));
                    });
                    echarts_4(cdNumberArray2, cdDateArray2);
                });
            });
        });
        $('.tab_right .cc').click();

        
    }
    function data_2(){
        $(".index_nav ul li").each(function (index) {
            $(this).click(function () {
                $(this).addClass("nav_active").siblings().removeClass("nav_active");
                $(".index_tabs .inner").eq(index).fadeIn().siblings("div").stop().hide();
                // console.log('tuceng', map.getLayers());

                if (index == 1) {
                    // map.getLayers().forEach(function (layer) {
                    //     if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer2') {
                    //         layer.setVisible(true);
                    //     }
                    //     if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer1') {
                    //         layer.setVisible(false);
                    //     }

                    // });
                    
                    // oe.clear();
                    map2.setTarget('map2');
                    // vectorLayer2.setVisible(true);
                    // map.getLayers().push(vectorLayer2)
                    multiplePoint2();
                }
                if(index == 0){
                    multiplePoint1();
                    map.getLayers().forEach(function (layer) {
                        console.log()
                        // if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer2') {
                        //     // layer.setVisible(false);
                        //     console.log('11111111111', layer.setVisible())
                        // }
                        if (layer.getProperties().name != undefined && layer.getProperties().name == 'base_Layer1') {
                            // layer.setVisible(true);
                            if (layer.getVisible()){
                                vectorLayer2.setVisible(false);
                            }
                            
                        }

                    });
                    echarts_1();
                    
                    // oe = new ADLayer(option, map, echarts)
                    // oe.render();
                    // map.removeLayer(vectorLayer2)
                    
                }
            })
        });
        
        
    }
 	/*function echarts_1() {
        var cdname = [], cdnumber = [];
        data.cd_data.forEach(element => {
            cdname.push(element.cd_name);
            cdnumber.push(element.cd_number);
        });
 		// 基于准备好的dom，初始化echarts实例
 		var myChart = echarts.init(document.getElementById('echart1'));

          var xdata = cdname;
          var series = [
              {
                  name: '库存',
                  type: 'bar',
                  barWidth: '30',
                  data: cdnumber
              }
          ]
          option = {
              tooltip: {
                  trigger: 'axis',
                  axisPointer: {
                      type: 'shadow'
                  }
              },
              "color": ["#62c98d"],//["#62c98d",  "#2f89cf"], 
              grid: {
                  top: '14%',
                  left: '15',
                  right: '35',
                  bottom: '12%',
                  containLabel: true
              },

              xAxis: [{
                  type: 'category',
                  axisLabel: { textStyle: { color: "rgba(255,255,255,.6)", } },
                  axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
                  data: xdata,
              }],
              yAxis: [{
                  name: '',
                  type: 'value',
                  axisTick: { show: false },
                  splitLine: {
                      show: true,
                      lineStyle: {
                          color: "#2f2a7a"
                      }
                  }, //x轴线
                  axisLabel: {
                      formatter: '{value}',
                      textStyle: { color: 'rgba(255,255,255,.6)' }
                  },
                  axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
              }],
              series: series
            }

 		// 使用刚指定的配置项和数据显示图表。
 		myChart.setOption(option);
 		window.addEventListener("resize", function () {
 			myChart.resize();
 		});
 	}*/

     function echarts_1() {
        //  $.ajax({
        //      type: "POST",
        //      url: config.webUrl + "/FoodSupply/getfoodsupply",
        //      data: {
        //          tbtime: '2017'
        //      },

        //      dataType: "json",
        //      success: function (relust) {
        //          console.log(relust);
        //         let data = relust.data
        //         for (let i = 0; i < relust.data.length; i++) {
                    
                    
        //         }
        //      },
        //      error: function () {
                 
        //      }
        //  });
         var gywdData = []
         var cdname = [], cdnumber = [];
         data.cd_data.forEach(element => {
             cdname.push(element.cd_name);
             cdnumber.push(element.cd_number);
         });
         var xdata = cdname;
         var series = [
             {
                 name: '库存',
                 type: 'bar',
                 barWidth: '30',
                 data: cdnumber
             }
         ]
         var myChart = echarts.init(document.getElementById('echart1'));
         option = {
             tooltip: {
                 trigger: 'axis',
                 axisPointer: {
                     type: 'shadow'
                 }
             },
             "color": ["#62c98d"],//["#62c98d",  "#2f89cf"], 
             grid: {
                 top: '14%',
                 left: '15',
                 right: '35',
                 bottom: '12%',
                 containLabel: true
             },

             xAxis: [{
                 type: 'category',
                 axisLabel: { textStyle: { color: "rgba(255,255,255,.6)", } },
                 axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
                 data: xdata,
             }],
             yAxis: [{
                 name: '',
                 type: 'value',
                 axisTick: { show: false },
                 splitLine: {
                     show: true,
                     lineStyle: {
                         color: "#2f2a7a"
                     }
                 }, //x轴线
                 axisLabel: {
                     formatter: '{value}',
                     textStyle: { color: 'rgba(255,255,255,.6)' }
                 },
                 axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
             }],
             series: series
         }
         myChart.setOption(option);
         window.addEventListener("resize", function () {
             myChart.resize();
         });
     }
     function echarts_2(data1, data2, data3) {
 		// 基于准备好的dom，初始化echarts实例
 		var myChart = echarts.init(document.getElementById('echart2'));
 		var vdata = [ data3, data2 ];
        var xdata = data1;
 		var ydata = ['警戒线库存高', '库存'];
        var series = [];
        $.each(vdata, function (index, val) {
            var series_option = {
                name: ydata[index],
                type: 'bar',
                itemStyle: {
                    normal: { color: '' }
                },
                barWidth: '30',
                data: val
            };
            series.push(series_option);
        })
 		
 		option = {
 			legend: {
 				data: ydata,
 				type: 'scroll',
				 textStyle: {color: "#fff"},
 				top: '0'
 			},
 			tooltip: {
 				trigger: 'axis',
 				axisPointer: {
 					type: 'shadow'
 				}
 			},
			"color": ["red", "#62c98d"],//["#62c98d",  "#2f89cf"], 
 			grid: {
 				top: '14%',
 				left: '15',
 				right: '35',
 				bottom: '12%',
 				containLabel: true
 			},
			
 			xAxis: [{
 				type: 'category',
				axisLabel:  {textStyle: {color: "rgba(255,255,255,.6)",}},
				axisLine: {lineStyle: { color: 'rgba(255,255,255,.1)'}},
				data: xdata,
 				}],
 			yAxis: [{
 				name: '',
 				type: 'value',
				axisTick: {show: false},
					splitLine: {
 					show: true,
 					lineStyle: {
 						color: "#2f2a7a"
 					}
 				}, //x轴线
 				axisLabel: {textStyle: {color: 'rgba(255,255,255,.6)'}},
				axisLine: {lineStyle: {color: 'rgba(255,255,255,.1)'}},
 			}],
 			/*"dataZoom": [{
 				"show": true,
 				"height": 12,
 				"xAxisIndex": [
 					0
 				],
 				bottom: 5,
 				"start": 10,
 				"end": 80,
 				handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
 				handleSize: '110%',
 				handleStyle: {
 					color: "#d3dee5",
 				},

 				textStyle: {
 					color: "#fff"
 				},
 				borderColor: "rgba(255,255,255,.3)"

 			}],*/
 			series: series
 		};
 		// 使用刚指定的配置项和数据显示图表。
 		myChart.setOption(option,true);
 		window.addEventListener("resize", function () {
 			myChart.resize();
 		});
 	}
	 function echarts_3() {
		 var myChart = echarts.init(document.getElementById('echart3'));
 		var geoCoordMap = {
    '上海': [121.4648,31.2891],
    '东莞': [113.8953,22.901],
    '东营': [118.7073,37.5513],
    '中山': [113.4229,22.478],
    '临汾': [111.4783,36.1615],
    '临沂': [118.3118,35.2936],
    '丹东': [124.541,40.4242],
    '丽水': [119.5642,28.1854],
    '乌鲁木齐': [87.9236,43.5883],
    '佛山': [112.8955,23.1097],
    '保定': [115.0488,39.0948],
    '兰州': [103.5901,36.3043],
    '包头': [110.3467,41.4899],
    '北京': [116.4551,40.2539],
    '北海': [109.314,21.6211],
    '南京': [118.8062,31.9208],
    '南宁': [108.479,23.1152],
    '南昌': [116.0046,28.6633],
    '南通': [121.1023,32.1625],
    '厦门': [118.1689,24.6478],
    '台州': [121.1353,28.6688],
    '合肥': [117.29,32.0581],
    '呼和浩特': [111.4124,40.4901],
    '咸阳': [108.4131,34.8706],
    '哈尔滨': [127.9688,45.368],
    '唐山': [118.4766,39.6826],
    '嘉兴': [120.9155,30.6354],
    '大同': [113.7854,39.8035],
    '大连': [122.2229,39.4409],
    '天津': [117.4219,39.4189],
    '太原': [112.3352,37.9413],
    '威海': [121.9482,37.1393],
    '宁波': [121.5967,29.6466],
    '宝鸡': [107.1826,34.3433],
    '宿迁': [118.5535,33.7775],
    '常州': [119.4543,31.5582],
    '广州': [113.5107,23.2196],
    '廊坊': [116.521,39.0509],
    '延安': [109.1052,36.4252],
    '张家口': [115.1477,40.8527],
    '徐州': [117.5208,34.3268],
    '德州': [116.6858,37.2107],
    '惠州': [114.6204,23.1647],
    '成都': [103.9526,30.7617],
    '扬州': [119.4653,32.8162],
    '承德': [117.5757,41.4075],
    '拉萨': [91.1865,30.1465],
    '无锡': [120.3442,31.5527],
    '日照': [119.2786,35.5023],
    '昆明': [102.9199,25.4663],
    '杭州': [119.5313,29.8773],
    '枣庄': [117.323,34.8926],
    '柳州': [109.3799,24.9774],
    '株洲': [113.5327,27.0319],
    '武汉': [114.3896,30.6628],
    '汕头': [117.1692,23.3405],
    '江门': [112.6318,22.1484],
    '沈阳': [123.1238,42.1216],
    '沧州': [116.8286,38.2104],
    '河源': [114.917,23.9722],
    '泉州': [118.3228,25.1147],
    '泰安': [117.0264,36.0516],
    '泰州': [120.0586,32.5525],
    '济南': [117.1582,36.8701],
    '济宁': [116.8286,35.3375],
    '海口': [110.3893,19.8516],
    '淄博': [118.0371,36.6064],
    '淮安': [118.927,33.4039],
    '深圳': [114.5435,22.5439],
    '清远': [112.9175,24.3292],
    '温州': [120.498,27.8119],
    '渭南': [109.7864,35.0299],
    '湖州': [119.8608,30.7782],
    '湘潭': [112.5439,27.7075],
    '滨州': [117.8174,37.4963],
    '潍坊': [119.0918,36.524],
    '烟台': [120.7397,37.5128],
    '玉溪': [101.9312,23.8898],
    '珠海': [113.7305,22.1155],
    '盐城': [120.2234,33.5577],
    '盘锦': [121.9482,41.0449],
    '石家庄': [114.4995,38.1006],
    '福州': [119.4543,25.9222],
    '秦皇岛': [119.2126,40.0232],
    '绍兴': [120.564,29.7565],
    '聊城': [115.9167,36.4032],
    '肇庆': [112.1265,23.5822],
    '舟山': [122.2559,30.2234],
    '苏州': [120.6519,31.3989],
    '莱芜': [117.6526,36.2714],
    '菏泽': [115.6201,35.2057],
    '营口': [122.4316,40.4297],
    '葫芦岛': [120.1575,40.578],
    '衡水': [115.8838,37.7161],
    '衢州': [118.6853,28.8666],
    '西宁': [101.4038,36.8207],
    '西安': [109.1162,34.2004],
    '贵阳': [106.6992,26.7682],
    '连云港': [119.1248,34.552],
    '邢台': [114.8071,37.2821],
    '邯郸': [114.4775,36.535],
    '郑州': [113.4668,34.6234],
    '鄂尔多斯': [108.9734,39.2487],
    '重庆': [107.7539,30.1904],
    '金华': [120.0037,29.1028],
    '铜川': [109.0393,35.1947],
    '银川': [106.3586,38.1775],
    '镇江': [119.4763,31.9702],
    '长春': [125.8154,44.2584],
    '长沙': [113.0823,28.2568],
    '长治': [112.8625,36.4746],
    '阳泉': [113.4778,38.0951],
    '青岛': [120.4651,36.3373],
    '韶关': [113.7964,24.7028]
};
var BJData = [
    [{name:'北京'}, {name:'上海',value:95}],
    [{name:'北京'}, {name:'广州',value:90}],
    [{name:'北京'}, {name:'大连',value:80}],
    [{name:'北京'}, {name:'南宁',value:70}],
    [{name:'北京'}, {name:'南昌',value:60}],
    [{name:'北京'}, {name:'拉萨',value:50}],
    [{name:'北京'}, {name:'长春',value:40}],
    [{name:'北京'}, {name:'包头',value:30}],
    [{name:'北京'}, {name:'重庆',value:20}],
    [{name:'北京'}, {name:'常州',value:10}]
];

var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';

var convertData = function (data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var dataItem = data[i];
        var fromCoord = geoCoordMap[dataItem[0].name];
        var toCoord = geoCoordMap[dataItem[1].name];
        if (fromCoord && toCoord) {
            res.push([{
                coord: fromCoord
            }, {
                coord: toCoord
            }]);
        }
    }
    return res;
};
var color = ['#fff'];
var series = [];
[['北京', BJData]].forEach(function (item, i) {
    series.push({
        name: item[0] + '',
        type: 'lines',
       // zlevel: 1,	
        effect: {
            show: true,
            period: 6,
            trailLength: 0.7,
            color: '#fff',
            symbolSize: 3
        },
        lineStyle: {
            normal: {
                color: color[i],
                width: 0,
				
                curveness: 0.2
            }
        },
        data: convertData(item[1])
    },
    {
        name: item[0] ,
        type: 'lines',
        zlevel: 2,
        effect: {
            show: true,
            period: 6,
            trailLength: 0,
            symbol: planePath,
            symbolSize: 15
        },
        lineStyle: {
            normal: {
                color: color[i],
                width: 1,
                opacity: 0.4,
                curveness: 0.2
            }
        },
        data: convertData(item[1])
    },
    {
        name: item[0] ,
        type: 'effectScatter',
        coordinateSystem: 'geo',
        zlevel: 2,
        rippleEffect: {
            brushType: 'stroke'
        },
        label: {
            normal: {
                show: true,
				fontSize:16,
				color:'#fff',
                position: 'right',
                formatter: '{b}'
            }
        },
        symbolSize:'10',
		/**symbolSize: function (val) {
            return val[2] / 8;
        },**/
        itemStyle: {
            normal: {
                color: color[i]
            }
        },
        data: item[1].map(function (dataItem) {
            return {
                name: dataItem[1].name,
                value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
            };
        })
    });
});
option = {
  //  backgroundColor: '#404a59',
    title : {
        text: '全国发展路线图',
        subtext: '副标题，不需要主删除此行',
        left: 'center',
        top: '13%',
        textStyle: {
            color: '#fff'
        }
    },
    geo: {
        map: 'china',
        label: {
            emphasis: {
                show: false
            }
        },
        roam: true,
        itemStyle: {
            normal: {
                areaColor: '#2a91e2',
                borderColor: '#0165b4'
            },
            emphasis: {
                areaColor: '#306de8'
            }
        }
    },
    series:series
};
 		// 使用刚指定的配置项和数据显示图表。
 		myChart.setOption(option);
 		window.addEventListener("resize", function () {
 			myChart.resize();
 		});
 	}
     function echarts_4(cdNumberArray, cdDateArray) {
        var myChart = echarts.init(document.getElementById('echart4'));

        option = {
            tooltip: {
                
                trigger: 'axis',
                axisPointer: {
                    lineStyle: {
                        color: '#57617B'
                    }
                },
                formatter: '{b}:<br/> 出库量{c}'
            },

            grid: {
                left: '8',
                right: '20',
                top:'10',
                bottom: '35',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                boundaryGap: false,
                axisLabel: {
                    show: true,
                    textStyle: {
                                color: 'rgba(255,255,255,.6)'
                                }
                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.1)'
                    }
                },
                data: cdDateArray
            }],
            yAxis: [{
                axisLabel: {
                    show: true,
                    textStyle: {
                                color: 'rgba(255,255,255,.6)'
                                }
                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.1)'
                    }
                },
                splitLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.1)'
                    }
                }
            }],
            "dataZoom": [{
                "show": true,
                "height": 12,
                "xAxisIndex": [
                    0
                ],
                bottom: 15,
                "start": 10,
                "end": 80,
                handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                handleSize: '110%',
                handleStyle: {
                    color: "#d3dee5",
                },

                textStyle: {
                    color: "#fff"
                },
                borderColor: "rgba(255,255,255,.3)"

            }],
            series: [{
                name: '出库量',
                type: 'line',
                smooth: true,
                symbol: 'circle',
                symbolSize: 5,
                showSymbol: false,
                lineStyle: {
                    normal: {
                        width: 3
                    }
                },

                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(98, 201, 141, 0.5)'
                        }, {
                            offset: 1,
                            color: 'rgba(98, 201, 141, 0.1)'
                        }], false),
                        shadowColor: 'rgba(0, 0, 0, 0.1)',
                        shadowBlur: 10
                    }
                },
                itemStyle: {
                    normal: {
                        color: '#4cb9cf',
                        borderColor: 'rgba(98, 201, 141,0.27)',
                        borderWidth: 12
                    }
                },
                data: cdNumberArray
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    }
     function echarts_5(data1, data2, maxstock, unit){
        var myChart = echarts.init(document.getElementById('echart2'));
        var xdata = data1;
        var series = [
             {
                name:'库存',
                type:'bar',
                barWidth: '30',
                data: data2,
                markLine: {
                    symbol: ['none', 'none'],//去掉箭头
                    itemStyle: {
                        normal: {
                            lineStyle: { type: 'solid', color: 'red' }
                            // , label: { show: false, position: 'left' }
                        }
                    },
                    data: [{
                        // name: 'Y 轴值为 100 的水平线',
                        yAxis: 86,
                        // valueDim: 'close'
                    }
                    ]
                }
            }, {
                name: '',
                type: 'bar',
                barWidth: '-10',
                data: [],
                markLine: {
                    symbol: ['none', 'none'],//去掉箭头
                    itemStyle: {
                        normal: {
                            lineStyle: { type: 'solid', color: 'yellow' }
                            // , label: { show: false, position: 'left' }
                        }
                    },
                    data: [{
                        // name: 'Y 轴值为 100 的水平线',
                        yAxis: 118,
                        // valueDim: 'close'
                    }
                    ]
                }
            }
        ]
        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            "color": ["#62c98d"],//["#62c98d",  "#2f89cf"], 
            grid: {
                top: '14%',
                left: '15',
                right: '35',
                bottom: '12%',
                containLabel: true
            },

            xAxis: [{
                type: 'category',
                axisLabel: { textStyle: { color: "rgba(255,255,255,.6)", } },
                axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
                data: xdata,
            }],
            yAxis: [{
                name: '',
                type: 'value',
                axisTick: { show: false },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: "#2f2a7a"
                    }
                }, //x轴线
                axisLabel: { 
                    formatter: '{value}' + unit,
                    textStyle: { color: 'rgba(255,255,255,.6)' } 
                },
                axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } },
            }],
            "dataZoom": [{
                "show": true,
                "height": 12,
                "xAxisIndex": [
                    0
                ],
                bottom: 15,
                "start": 10,
                "end": 80,
                handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                handleSize: '110%',
                handleStyle: {
                    color: "#d3dee5",
                },

                textStyle: {
                    color: "#fff"
                },
                borderColor: "rgba(255,255,255,.3)"

            }],
            series: series
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option, true);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    function data_3() {
        var id = data.storageData[0].cc_id;
        var cc_cd_ul = '<li><span>经度：</span><input type="number" class="cc_x" /></li>'
            + '<li> <span>纬度：</span> <input type="number" class="cc_y" /></li>'
            + '<li><span>仓储名称：</span><input type="text" class="cc_name"><input type="text" class="cc_id" style="display:none;"></li>'
            + '<li><span>仓储联系人：</span><input type="text" class="cc_lxr"></li>'
            + '<li><span>所在城市：</span><input type="text" class="cc_city"></li>'
            + '<li><span>行政编码：</span><input type="text" class="cc_citycode"></li>'
            + '<li><span>仓储地址：</span><input type="text" class="cc_address"></li>'
            + '<li><span>邮政编码：</span><input type="text" class="cc_postalcode"></li>'
            // + '<li><span>联系电话座机：</span><input type="text" class="cc_landline"></li>'
            + '<li><span>联系电话：</span><input type="text" class="cc_mobilephone"></li>'
        $(".sjgl_xz").click(function () {
            $(".cc_cd_ul").html(cc_cd_ul);
            $(".ccxx").show();
            $(".ccxx_xg").hide();
            $(".ccxx_bc").show();
            $(".ccxx_span1").html('新增信息');
            $(".ccxx_xzzd").show();
            $(".cc_zd").hide();
            $(".cc_zd ul").html('');
            if(data.field.length>0){
                for(var i=0; i< data.field.length; i++){
                    $(".cc_cd_ul").append('<li><span>'+data.field[i].fieldmc+'：</span><input type="text" class='+data.field[i].field+'></li>');
                }
            }
            map2.on('singleclick', function (evt) {
                if ($(".ccxx").css('display') == 'none'){
                    return;
                }
                var coordinate = evt.coordinate;
                var jd = coordinate[0], wd = coordinate[1];
                $('.cc_x').val(jd);
                $('.cc_y').val(wd);
                addPoint(jd, wd);
            });
            
        });
        // xinzeng
        $(".ccxx_bc").click(function () {
            var id_cc = $(".cc_citycode").val() + '-' + _.filter(data.storageData,{cc_citycode:$(".cc_citycode").val()}).length +1
			console.log(_.filter(data.storageData,{cc_citycode:$(".cc_citycode").val()}));
            var obj ={
                "cc_name": $(".cc_name").val(),
                "cc_id": id_cc,
                "cc_postalcode": $(".cc_postalcode").val(),
                "cc_citycode": $(".cc_citycode").val(),
                "cc_x": $(".cc_x").val(),
                "cc_y": $(".cc_y").val(),
                "cc_lxr": $(".cc_lxr").val(),
                "cc_city": $(".cc_city").val(),
                "cc_landline": $(".cc_landline").val(),
                "cc_mobilephone": $(".cc_mobilephone").val(),
                "cc_address": $(".cc_address").val(),
            }
            if(data.field.length>0){
                for(var i=0; i< data.field.length; i++){
                    obj[data.field[i].field] = $('.zd').eq(i).val();
                }
            }
            data.storageData.push(
                obj
            );
            alert('保存成功！');
            multiplePoint2();
            $(".ccxx").hide();
            $(".ccData").append('<tr>'
                + '<td>' + $(".cc_name").val() + '</td>'
                + '<td>' + $(".cc_lxr").val() + '</td>'
                + '<td>' + $(".cc_mobilephone").val() + '</td>'
                + '<td>' + $(".cc_city").val() + '</td>'
                + '<td><input value=' + id_cc + ' style="display:none;" /><span class="modification" title="修改"><i class="fa fa-pencil"></i></span><span class="delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'
            +'</tr >');
            data_4();
        });
        $(".ccxx_xg").click(function(){
            var findIndex = _.findIndex(data.storageData,{"cc_id":id});
            var obj2 = {
                "cc_name": $(".cc_name").val(),
                "cc_id": $(".cc_id").val(),
                "cc_postalcode": $(".cc_postalcode").val(),
                "cc_citycode": $(".cc_citycode").val(),
                "cc_x": $(".cc_x").val(),
                "cc_y": $(".cc_y").val(),
                "cc_lxr": $(".cc_lxr").val(),
                "cc_city": $(".cc_city").val(),
                "cc_landline": $(".cc_landline").val(),
                "cc_mobilephone": $(".cc_mobilephone").val(),
                "cc_address": $(".cc_address").val(),
                "cc_citycode": $(".cc_citycode").val(),
                }
                if(data.field.length>0){
                    for(var i=0; i< data.field.length; i++){
                        obj2[data.field[i].field] = $('.'+data.field[i].field+'').val();
                    }
                }
            data.storageData[findIndex] = obj2
            console.log(obj2);
            $(".ccxx").hide();
        });
        $(".cczd_bc").click(function(){
                data.field.push({fieldmc:$('.zdmc').val(),field:$('.zddm').val()});
                $(".cc_cd_ul").append('<li><span>'+$('.zdmc').val()+'：'+'</span><input type="text" class="zd"></li>');
                $('.cc_zd ul').html('');
                $(".cc_zd").hide();
             console.log(data.field);   
        });
        // $('#pagination').pagination({
        //     pageCount: 2,
        //     coping: false,
        //     count: 2,
        //     prevContent: '<上一页',
        //     nextContent: '下一页>',
        //     callback: function (index) {
        //         var current = index.getCurrent();
        //         console.log(current);
        //     }
        // });
        var cc_table = "",  name = data.storageData[0].cc_name;
        data.storageData.forEach(element => {
            cc_table += '<tr>'
                + '<td>'+element.cc_name+'</td>'
                + '<td>' + element.cc_lxr+'</td>'
                + '<td>'+element.cc_mobilephone+'</td>'
                + '<td>' + element.cc_city+'</td>'
                + '<td><input value=' + element.cc_id +' style="display:none;" /><span class="modification" title="修改"><i class="fa fa-pencil"></i></span><span class="delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'
            '</tr >'
        });
        $(".ccData").html(cc_table);
        // cd();
        // function cd(){
            
            function rk(){
                $('.ck_rk a').removeClass('active3');
                $('.ck_rk .rk').addClass('active3');
                $('.cc_rk').show();
                $('.cc_ck').hide();
                var date = new Date();//(new Date()).getTime();
                var cd_cc_array = _.filter(data.rk_cd, { 'rk_cc_id': id });
                // var array = [];
                // for (i = 0; i < cd_cc_array.length; i++) {
                //     if (parseInt(new Date(cd_cc_array[i].rk_date).getTime()) >= parseInt(new Date(date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate()).getTime())) {
                //         array.push(cd_cc_array[i]);
                //     }
                // }
                var cd_table = "";
                var uniqArray = _.uniqBy(cd_cc_array, "rk_cd_id");
                console.log('------------',uniqArray);
                uniqArray.forEach(element => {
                    var cdData = data.cd_data[_.findIndex(data.cd_data, { 'cd_id': element.rk_cd_id })];
                    var cd_table_data = _.filter(cd_cc_array, { 'rk_cd_id': element.rk_cd_id, 'rk_date': _.maxBy(_.filter(cd_cc_array, { 'rk_cd_id': element.rk_cd_id }), 'rk_date').rk_date })
                    var cknumber = _.maxBy(_.filter(data.ck_cd,{ck_cd_id:element.rk_cd_id,ck_cc_id:element.rk_cc_id}),'ck_date');
                    var number = '';
                    if(cknumber == undefined){
                        number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock);
                    }else{
                        if(parseInt(cd_table_data[0].rk_date) >= parseInt(cknumber.ck_date)){
                            number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock);
                        } else {
                            number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock) - parseInt(cknumber.ck_number)
                        }
                    }
                    cd_table += '<tr>'
                        + '<td>' + cdData.cd_name + '</td>'
                        + '<td>' + cdData.cd_type + '</td>'
                        + '<td>' + number + cdData.cd_unit + '</td>'
                        + '<td style="width: 130px;"><input value=' + cd_table_data[0].rk_cd_id + ' style="display:none;" /><button class="cdData_rk">入库</button></td>'
                        + '</tr>'
                });
                $(".cdData").html(cd_table);
                $(".cdData_rk").click(function () {
                    $('.cd_span1').html('商品入库');
                    $('.cd_bc').hide();
                    $('.cd_ck_bc').hide();
                    $('.cd_rk_bc').show();
                    var cdname = _.filter(data.cd_data, { 'cd_id': $(this).siblings('input').val() });
                    var rkdata = _.maxBy(_.filter(data.rk_cd, { 'rk_cc_id': id, 'rk_cd_id': $(this).siblings('input').val() }), 'rk_date');
                    var ckdata = _.maxBy(_.filter(data.ck_cd, { 'ck_cc_id': id, 'ck_cd_id': $(this).siblings('input').val() }), 'ck_date');
                    var dq_number = ''
                    if(ckdata == undefined){
                        dq_number = parseInt(rkdata.rk_number) + parseInt(rkdata.rk_curstock);
                    }else{
                        if(parseInt(rkdata.rk_date) >= parseInt(ckdata.ck_date)){
                            dq_number = parseInt(rkdata.rk_number) + parseInt(rkdata.rk_curstock);
                        } else {
                            dq_number = parseInt(rkdata.rk_number) + parseInt(rkdata.rk_curstock) - parseInt(ckdata.ck_number);
                        }
                    }
                    var cd_ul_li = '<li><span>仓储名称：</span><input type="text" value=' + name + ' readonly /><input class="rk_cc_id" type="text" value=' + id + ' style="display:none;" /></li>'
                        + '<li> <span>商品名称：</span> <input type="text" value=' + cdname[0].cd_name + ' readonly /><input class="rk_cd_id" type="text" value=' + $(this).siblings('input').val() + ' style="display:none;" /></li>'
                        + '<li><span>当前库存：</span><input class="rk_curstock" type="number" value=' + dq_number + ' readonly /></li>'
                        + '<li><span>入库数量：</span><input class="rk_number" type="number" /></li>'
                    // +'<li><span>入库时间：</span><input type="date"></li>'
                    $(".cd_div").show();
                    $(".cd_ul").html(cd_ul_li);
                });
            }
            rk();
            $('.ck_rk .rk').click(function () {
                rk();
            });
            function ck(){
                $('.cc_ck').hide();
                $('.cc_rk').hide();
                var date = new Date();//(new Date()).getTime();
                var cd_cc_array = _.filter(data.rk_cd, { 'rk_cc_id': id });
                // var array = [];
                // for (i = 0; i < cd_cc_array.length; i++) {
                //     if (parseInt(new Date(cd_cc_array[i].rk_date).getTime()) >= parseInt(new Date(date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate()).getTime())) {
                //         array.push(cd_cc_array[i]);
                //     }
                // }
                var cd_table = "";
                var uniqArray = _.uniqBy(cd_cc_array, "rk_cd_id");
                console.log('------------',uniqArray);
                uniqArray.forEach(element => {
                    var cdData = data.cd_data[_.findIndex(data.cd_data, { 'cd_id': element.rk_cd_id })];
                    var cd_table_data = _.filter(cd_cc_array, { 'rk_cd_id': element.rk_cd_id, 'rk_date': _.maxBy(_.filter(cd_cc_array, { 'rk_cd_id': element.rk_cd_id }), 'rk_date').rk_date })
                    var cknumber = _.maxBy(_.filter(data.ck_cd,{ck_cd_id:element.rk_cd_id,ck_cc_id:element.rk_cc_id}),'ck_date');
                    var dqkc_number = '';
                    if(cknumber == undefined){
                        dqkc_number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock);
                    }else{
                        if(parseInt(cd_table_data[0].rk_date) >= parseInt(cknumber.ck_date)){
                            dqkc_number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock);
                        } else {
                            dqkc_number = parseInt(cd_table_data[0].rk_number) + parseInt(cd_table_data[0].rk_curstock) - parseInt(cknumber.ck_number)
                        }
                    }
                    
                    cd_table += '<tr>'
                        + '<td>' + cdData.cd_name + '</td>'
                        + '<td>' + cdData.cd_type + '</td>'
                        + '<td>' + dqkc_number + cdData.cd_unit + '</td>'
                        + '<td style="width: 130px;"><input value=' + cd_table_data[0].rk_cd_id + ' style="display:none;" /><button class="cdData_ck">出库</button></td>'
                        + '</tr>'
                });
                $(".cdData").html(cd_table);
                $(".cdData_ck").click(function () {
                    $('.cd_span1').html('商品出库');
                    $('.cd_rk_bc').hide();
                    $('.cd_ck_bc').show();
                    $('.cd_bc').hide();
                    var cdname = _.filter(data.cd_data, { 'cd_id': $(this).siblings('input').val() });
                    console.log('============',cdname);
                    //var rkdata = _.maxBy(_.filter(data.rk_cd, { 'rk_cc_id': id, 'rk_cd_id': $(this).siblings('input').val() }), 'rk_date');
                    var cd_ul_li = '<li><span>仓储名称：</span><input type="text" value=' + name + ' readonly /><input type="text" class="ck_cc_id2" value=' + id + ' style="display:none;" /></li>'
                        + '<li> <span>商品名称：</span> <input type="text"  value=' + cdname[0].cd_name + ' readonly /><input type="text" class="ck_cd_id2" value=' + $(this).siblings('input').val() + ' style="display:none;"</li>'
                        + '<li><span>出库数量：</span><input type="number" class="ck_number2" /></li>'
                    // + '<li><span>出库时间：</span><input type="date"></li>'
                    $(".cd_div").show();
                    $(".cd_ul").html(cd_ul_li);
                });
            }
        $('.cd_ck_bc').click(function () {
            var myDate = new Date();
            data.ck_cd.push({
                "ck_cc_id": $('.ck_cc_id2').val(),
                "ck_cd_id": $('.ck_cd_id2').val(),
                "ck_date": (new Date()).getTime(),//.getFullYear() + "-" +(myDate.getMonth()+1) + "-" +myDate.getDate(),
                "ck_number": $('.ck_number2').val(),
            });
            $(".cd_div").hide();

            ck();
        });
            $('.ck_rk .ck').click(function () {
                ck();
            });
            $(".cc_rk").click(function () {
                $('.cd_span1').html('添加商品');
                $('.cd_rk_bc').hide();
                $('.cd_ck_bc').hide();
                $('.cd_bc').show();
                var tjcd = '<li><span>选择商品：</span><select>'
                data.cd_data.forEach(element => {
                    tjcd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                });
                tjcd += '</select></li>';
                tjcd += '<li><span>入库数量：</span><input type="number" value="" class="rk_sl" /></li>'
                $(".cd_div").show();
                $(".cd_ul").html(tjcd);
            });
            //tianjiashangpin
            
            
            
            
            
        // }
        $('.cd_bc').click(function () {

            var rk_length = _.uniqBy(data.rk_cd, { rk_cd_id: $('.cd_ul select option:selected').val(), rk_cc_id: id });
            for (i = 0; i < rk_length.length; i++) {
                if ($('.cd_ul select option:selected').val() == rk_length[i].rk_cd_id) {
                    alert('已有该商品，请从新选择！');
                    return;
                }
            }
            var select_data = _.filter(data.cd_data, { cd_id: $('.cd_ul select option:selected').val() })[0];
            $(".cdData").append('<tr>'
                + '<td>' + select_data.cd_name + '</td>'
                + '<td>' + select_data.cd_type + '</td>'
                + '<td>' + $('.rk_sl').val() + '</td>'
                + '<td style="width: 130px;"><input value=' + select_data.rk_cd_id + ' style="display:none;" /><button class="cdData_rk">入库</button></td>'
                + '</tr>');
            $(".cd_div").hide();
            // var myDate = new Date();
            data.rk_cd.push({
                "rk_cc_id": id,
                "rk_cd_id": $('.cd_ul select option:selected').val(),
                "rk_date": (new Date()).getTime(),//myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate(),
                "rk_number": $('.rk_sl').val(),
                "rk_curstock": "0"
            });
            alert("保存成功");
            rk();
        });
        $('.cd_rk_bc').click(function(){
            var myDate = new Date();
            data.rk_cd.push({
                "rk_cc_id": $('.rk_cc_id').val(),
                "rk_cd_id": $('.rk_cd_id').val(),
                "rk_date": (new Date()).getTime(),//myDate.getFullYear() + "-" +(myDate.getMonth()+1) + "-" +myDate.getDate(),
                "rk_number": $('.rk_number').val(),
                "rk_curstock": $('.rk_curstock').val()
            });
            $(".cd_div").hide();
            console.log( $('.rk_number').val());
            rk();
        });
        
        $(".ccData tr").click(function () {
            id = $(this).children().children('input').val();
            rk();
            var cc = _.filter(data.storageData, {'cc_id': id});
            console.log(cc[0].cc_x, cc[0].cc_y);
            map2.getView().animate({
                center: [cc[0].cc_x, cc[0].cc_y],
                duration: 0,
                zoom: 5,
            });
            var feature = new ol.Feature({
                geometry: new ol.geom.Point([cc[0].cc_x, cc[0].cc_y]),
            });
            feature.flatCoordinates_ = [cc[0].cc_x, cc[0].cc_y];
            var tempVectorSource = new ol.source.Vector({
                features: [feature]
            });
            var tempIconStyle = new ol.style.Style({
                image: new ol.style.Circle({
                    radius: 8,
                    fill: new ol.style.Fill({
                        color: 'red'
                    })
                })
            });
            if (tempVectorLayer == null) {
                tempVectorLayer = new ol.layer.Vector({
                    source: tempVectorSource,
                    style: tempIconStyle
                });
                map2.getLayers().push(tempVectorLayer);
            } else {
                tempVectorLayer.setSource(tempVectorSource);
            }
        });
        function xg(){
            
        var cdb_table = '';
        data.cd_data.forEach(element => {
            cdb_table += '<tr>'
                +'<td>'+element.cd_name+'</td>'
                +'<td>' + element.cd_type +'</td>'
                +'<td>' + element.cd_number + element.cd_unit +'</td>'
                +'<td>' + element.cd_manufacturer +'</td>'
                + '<td><input value=' + element.cd_id +' style="display:none;" /><span class="cd_modification" title="修改"><i class="fa fa-pencil"></i></span><span class="cd_delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'
            '</tr>' 
        });
        // + '<td><input value=' + element.cd_id+' style="display:none;" /><span class="cd_modification" title="修改"><i class="fa fa-pencil"></i></span><span class="cd_delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'

        $(".cdb").html(cdb_table);
        var cd_ul_data = '<li><span>商品名称：</span><input type="text" class="cd_name"></li>'
            + '<li><span>商品编号：</span><input type="text" class="cd_id"></li>'
            + '<li><span>商品类型：</span><input type="text" class="cd_type"></li>'
            + '<li><span>商品单位：</span><input type="text" class="cd_unit"></li>'
            + '<li><span>商品数量：</span><input type="number" class="cd_number"></li>'
            + '<li><span>制造商：</span><input type="text" class="cd_manufacturer"></li>'
            + '<li><span>警戒线低库存：</span><input type="number" class="cd_minstock"></li>'
            + '<li><span>警戒线高库存：</span><input type="number" class="cd_maxstock"></li>'
        
        $(".cd_modification").click(function(){
            $(".cdxx_span1").html('修改商品信息');
            $(".cdxx").show();
            $(".cdxx_ul ul").html(cd_ul_data);
            var cd_1 = _.filter(data.cd_data,{cd_id:$(this).siblings('input').val()})[0];
            $(".cd_id").val(cd_1.cd_id)
                $(".cd_name").val(cd_1.cd_name)
                $(".cd_type").val(cd_1.cd_type)
                $(".cd_unit").val(cd_1.cd_unit)
                $(".cd_number").val(cd_1.cd_number)
                $(".cd_manufacturer").val(cd_1.cd_manufacturer)
                $(".cd_minstock").val(cd_1.cd_minstock)
                $(".cd_maxstock").val(cd_1.cd_maxstock)
            $('.ccxx_bc3').show();
            $('.ccxx_bc2').hide();
            $('.ccxx_bc4').hide();
        });
        $(".cd_delete").click(function () {
            if (confirm('确定要删除？')) {
                $(this).parents('tr').remove();
                // console.log(_.filter(data.storageData, { "cc_id": $(this).siblings('input').val() }));
                data.storageData.splice(_.filter(data.storageData, { "cc_id": $(this).siblings('input').val() }), 1);
                $('.ccxx_bc4').show();
                $('.ccxx_bc3').hide();
                $('.ccxx_bc2').hide();
            }
        });
    }
    xg();
        $(".sjgl_xz3").click(function () {
            var cd_ul_data = '<li><span>商品名称：</span><input type="text" class="cd_name"></li>'
            + '<li><span>商品编号：</span><input type="text" class="cd_id"></li>'
            + '<li><span>商品类型：</span><input type="text" class="cd_type"></li>'
            + '<li><span>商品单位：</span><input type="text" class="cd_unit"></li>'
            + '<li><span>商品数量：</span><input type="number" class="cd_number"></li>'
            + '<li><span>制造商：</span><input type="text" class="cd_manufacturer"></li>'
            + '<li><span>警戒线低库存：</span><input type="number" class="cd_minstock"></li>'
            + '<li><span>警戒线高库存：</span><input type="number" class="cd_maxstock"></li>'
            $(".cdxx_span1").html('新增商品信息');
            $(".cdxx").show();
            $(".cdxx_ul ul").html(cd_ul_data);
            $('.ccxx_bc2').show();
            $('.ccxx_bc3').hide();
            $('.ccxx_bc4').hide();
        });
        $('.ccxx_bc3').click(function(){
            var cd_3 = data.cd_data[_.findIndex(data.cd_data, { "cd_id": $(".cd_id").val() })];
            var cdb_table = '';
            cd_3.cd_id=$(".cd_id").val(),
            cd_3.cd_name=$(".cd_name").val(),
            cd_3.cd_type=$(".cd_type").val(),
            cd_3.cd_unit=$(".cd_unit").val(),
            cd_3.cd_number=$(".cd_number").val(),
            cd_3.cd_manufacturer=$(".cd_manufacturer").val(),
            cd_3.cd_minstock=$(".cd_minstock").val(),
            cd_3.cd_maxstock=$(".cd_maxstock").val()
            // data.cd_data.forEach(element => {
            //     cdb_table += '<tr>'
            //         +'<td>'+element.cd_name+'</td>'
            //         +'<td>' + element.cd_type +'</td>'
            //         +'<td>' + element.cd_number + element.cd_unit +'</td>'
            //         +'<td>' + element.cd_manufacturer +'</td>'
            //         + '<td><input value=' + element.cd_id +' style="display:none;" /><span class="cd_modification" title="修改"><i class="fa fa-pencil"></i></span><span class="cd_delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'
            //     '</tr>' 
            // });
            // $(".cdb").html(cdb_table);
            xg();
            $(".cdxx").hide();
        });
        
        $('.ccxx_bc2').click(function () {
            var cd = {
                "cd_id": $(".cd_id").val(),
                "cd_name": $(".cd_name").val(),
                "cd_type": $(".cd_type").val(),
                "cd_unit": $(".cd_unit").val(),
                "cd_number": $(".cd_number").val(),
                "cd_manufacturer": $(".cd_manufacturer").val(),
                "cd_minstock": $(".cd_minstock").val(),
                "cd_maxstock": $(".cd_maxstock").val()
            }
            data.cd_data.push(cd);
            // var cd_cd = '<tr>'
            //     + '<td>' + $(".cd_name").val() + '</td>'
            //     + '<td>' + $(".cd_type").val() + '</td>'
            //     + '<td>' + $(".cd_number").val() + $(".cd_unit").val() + '</td>'
            //     + '<td>' + $(".cd_manufacturer").val() + '</td>'
            //     + '<td><input style="display:none;" value=' + $(".cd_id").val() + ' /><span class="cd_modification" title="修改"><i class="fa fa-pencil"></i></span><span class="cd_delete" title="删除"><i class="fa fa-trash-o"></i></span></td>'
            // '</tr>'
            // $('.cdb').append(cd_cd);
            xg();
            $(".cdxx").hide();
        });
        
    }
    function data_4() {
    $(function(){
        $(".ccxx_span2").click(function(){
            $(".ccxx").hide();
            $(".cdxx").hide();
            map2.removeLayer(tempVectorLayer);
            tempVectorLayer = null;
        });
        $(".ccxx_xzzd").click(function(){
            $(".cc_zd").show();
            $(".cc_zd ul").html("<li><span>字段名：</span><input class='zdmc' type='text' /></li><li><span>字段：</span> <input class='zddm' type='text' /></li>");
        });
        

        
        $(".modification").click(function(){
            var ccxg = _.filter(data.storageData, { "cc_id": $(this).siblings('input').val() })[0];
            
            var cc_cd_ul = '<li><span>经度：</span><input type="number" class="cc_x" value=' + ccxg.cc_x+' /></li>'
                + '<li> <span>纬度：</span> <input type="number" class="cc_y" value=' + ccxg.cc_y +' /></li>'
                + '<li><span>仓储名称：</span><input type="text" class="cc_name" value=' + ccxg.cc_name +'><input type="text" style="display:none" class="cc_id" value=' + ccxg.cc_id +'></li>'
                + '<li><span>仓储联系人：</span><input type="text" class="cc_lxr" value=' + ccxg.cc_lxr +'></li>'
                + '<li><span>所在城市：</span><input type="text" class="cc_city" value=' + ccxg.cc_city +'></li>'
                + '<li><span>行政编码：</span><input type="text" class="cc_citycode" value=' + ccxg.cc_citycode +'></li>'
                + '<li><span>仓储地址：</span><input type="text" class="cc_address" value=' + ccxg.cc_address +'></li>'
                + '<li><span>邮政编码：</span><input type="text" class="cc_postalcode" value=' + ccxg.cc_postalcode +'></li>'
                // + '<li><span>联系电话座机：</span><input type="text" class="cc_landline" value=' + ccxg.cc_landline +'></li>'
                + '<li><span>联系电话：</span><input type="text" class="cc_mobilephone" value=' + ccxg.cc_mobilephone +'></li>'
            $(".cc_cd_ul").html(cc_cd_ul);
            
            $(".ccxx").show();
            $(".ccxx_bc").hide();
            $(".ccxx_xg").show();
            $(".ccxx_span1").html('修改信息');
            $(".ccxx_xzzd").hide();
            $(".cc_zd").hide();
            $(".cc_zd ul").html('');
            if(data.field.length>0){
                for(var i=0; i< data.field.length; i++){
                    console.log(ccxg[data.field[i].field],'-----------');
                    var xzname = (ccxg[data.field[i].field] == undefined) ? '' : ccxg[data.field[i].field]
                    $(".cc_cd_ul").append('<li><span>'+data.field[i].fieldmc+'：</span><input type="text" class='+data.field[i].field+' value='+xzname+'></li>');
                }
            }
        });
        $(".delete").click(function(){
            if(confirm('确定要删除？')){
                $(this).parents('tr').remove();
                // console.log(_.filter(data.storageData, { "cc_id": $(this).siblings('input').val() }));
                data.storageData.splice(_.filter(data.storageData, { "cc_id": $(this).siblings('input').val() }), 1);
                console.log(data.storageData);
                
            }
        });
        
        $(".cd_span2").click(function(){
            $(".cd_div").hide();
        });
        $(".sjgl_left a").each(function (index) {
            $(this).click(function () {
                $(this).addClass("active1").siblings().removeClass("active1");
                $(".sjgl_tab").eq(index).fadeIn().siblings(".sjgl_tab").stop().hide();
                // if (index == 1) {
                //     yingXiao();
                // } else if (index == 2) {
                //     shouRu();
                // }
            })
        });
        $(".cdxx_span2").click(function(){
            $(".ccxx").hide();
            $(".cdxx").hide();
        });
        
        //定位跟踪
        $(".cldw").click(function(){
            $(".message").show();
            $(".zwxx").hide();
            if ($(".search_chose_box option:selected").val() == 1){
                $(".che").html('一号车');
            } else if ($(".search_chose_box option:selected").val() == 2) {
                $(".che").html('二号车');
            } else {
                $(".message").hide();
                $(".zwxx").show();
            }
        });
        
        //chuku---ruku
        $('.ck_rk a').click(function () {
            $('.ck_rk a').removeClass('active3');
            $(this).addClass('active3');
        });
    })
    }


    function data_tj(){
        var select_cc = '<option value='+0+'>---请选择---</option>',select_cd = '<option value='+0+'>---请选择---</option>';
        data.storageData.forEach(element => {
            select_cc += '<option value='+element.cc_id+'>'+element.cc_name+'</option>' 
        });
        $('#select_cc').html(select_cc);
        data.cd_data.forEach(element => {
            select_cd += '<option value='+element.cd_id+' selected = "selected">'+element.cd_name+'</option>' 
        });
        $('#select_cd').html(select_cd);

        $('#tj').click();
        $('#tj').click(function(){
            var table_tj1 = '<div class="map_title">商品出库</div><table class="table-bordered">'
        table_tj1 += '<thead><tr><th>出库时间</th><th>类型</th><th>出库数量</th><th>警戒线库存高</th><th>警戒线库存低</th></tr></thead><tbody>'
            if($('#select_cc option:selected').val() != 0 && $('#select_cd option:selected').val() != 0){
            var table_tj_data1 = _.filter(data.ck_cd, { 'ck_cc_id': $('#select_cc option:selected').val(),ck_cd_id: $('#select_cd option:selected').val()});
            table_tj_data1.forEach(element => {
                var cdData = data.cd_data[_.findIndex(data.cd_data, { 'cd_id': element.ck_cd_id })];
                table_tj1 += '<tr><td>'+element.ck_date+'</td>'
                    + '<td>'+cdData.cd_type+'</td>'
                    // + '<td>'+(parseInt(element.rk_number) + parseInt(element.rk_curstock))+'</td>'
                    + '<td>'+element.ck_number + cdData.cd_unit+'</td>'
                    + '<td>'+cdData.cd_maxstock+'</td>'
                    + '<td>'+cdData.cd_minstock+'</td></tr>'
                    
            });
            table_tj1 += '</tbody></table>'
            $("#table_tj1").html(table_tj1);

            

        }
            var table_tj2 = '<div class="map_title">商品库存</div><table class="table-bordered">'
            table_tj2 += '<thead><tr><th>仓储名称</th><th>商品名称</th><th>商品库存</th><th>入库数量</th><th>警戒线库存高</th><th>警戒线库存低</th></tr></thead><tbody>'
            if($('#select_cc option:selected').val() == 0 && $('#select_cd option:selected').val() != 0){
                var cd_table_tj = _.filter(data.rk_cd,{rk_cd_id:$('#select_cd option:selected').val(),'rk_date': _.maxBy(data.rk_cd,'rk_date').rk_date});
                console.log(cd_table_tj);
                cd_table_tj.forEach(element => {
                    
                    var cdcd = _.filter(data.cd_data,{cd_id:element.rk_cd_id})[0];
                    table_tj2 += '<tr><td>'+_.filter(data.storageData,{cc_id:element.rk_cc_id})[0].cc_name+'</td>' 
                        + '<td>'+cdcd.cd_name+'</td>'
                        + '<td>'+(parseInt(element.rk_curstock) + parseInt(element.rk_number))+'</td>'
                        + '<td>'+parseInt(element.rk_number)+'</td>'
                        + '<td>'+cdcd.cd_maxstock+'</td>'
                        + '<td>'+cdcd.cd_minstock+'</td></tr>'
                });
                table_tj2 += '</tbody></table>'
                $("#table_tj1").html(table_tj2);
            }
            // if ($('#select_cc option:selected').val() != 0 && $('#select_cd option:selected').val() == 0) {
            //     var table_tj3 = '<div class="map_title">商品库存</div><table class="table-bordered">'
            // }

            
        });
        $('.ul_li_rk').click(function () {
            $('.spxx').show();
            $('.psdxx').hide();
            $('.cb_tj_table').show();
            $('.jjx').hide();
            $('.header_table div').html('商品入库库存统计');
            $(this).addClass('active5').siblings().removeClass('active5');
            $('.cxtj_div1 select').val(0);
            $('.cxtj_div1 select').change(function () {
                var date1 = '<span>起始日期：</span><input type="date" class="qsrq" /><span>截止日期：</span><input type="date" class="jzrq" />'
                if ($(this).val() == 1) {
                    $('.cxtj_div2').html(date1 + '<button class="tj_lyzx1">查询</button>');
                    $('.tj_lyzx1').click(function () {
                        if ((new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var cd_rk_table = '<thead><tr><th>商品名称</th><th>入库数量</th><th>入库时间</th></tr></thead><tbody>'

                        data.cd_cd_rk.forEach(element => {
                            var date5 = _.filter(data.rk_cd, { rk_cd_id: element.cd_id });
                            var date4 = new Date(element.cd_rk_date);
                            // console.log(date5);
                            // for(i=0;i<date5.length;i++){
                            if (parseInt(element.cd_rk_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.cd_rk_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var date6 = _.join([new Date(element.cd_rk_date).getFullYear(), new Date(element.cd_rk_date).getMonth() + 1, new Date(element.cd_rk_date).getDate()], '-');

                                cd_rk_table += '<tr><td>' + element.cd_name + '</td>'
                                    + '<td>' + element.cd_number + element.cd_unit + '</td>'
                                    + '<td>' + date6 + '</td></tr>'
                            }
                            // }

                        });
                        console.log(data.cd_cd_rk);
                        cd_rk_table += '</tbody>';
                        $('.tj_table').html(cd_rk_table);
                    });
                } else if ($(this).val() == 2) {
                    var szcs = '<span>所在城市：</span><select class="szcs_id" style="margin-right:42px;margin-bottom:10px;">'
                    data.division.forEach(element => {
                        szcs += '<option value=' + element.cc_citycode + '>' + element.cc_city + '</option>'
                    });
                    szcs += '</select>'
                    var cd = '<span>商品：</span><select class="szcs_cd"><option value="0">所有商品</option>'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select><br>'
                    $('.cxtj_div2').html(szcs + cd + date1 + '<button class="tj_szcs">查询</button>');

                    $('.tj_szcs').click(function () {
                        $('.header_table div').html('库存统计');
                        if ($('.qsrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var szcs_cc = _.filter(data.storageData, { 'cc_citycode': $('.szcs_id').val() });
                        var szcs_cd = [];
                        console.log(szcs_cc);
                        szcs_cc.forEach(element => {
                            if ($('.szcs_cd option:selected').val() == 0) {
                                szcs_cd.push(_.filter(data.rk_cd, { rk_cc_id: element.cc_id }));
                            } else {
                                szcs_cd.push(_.filter(data.rk_cd, { rk_cc_id: element.cc_id, rk_cd_id: $('.szcs_cd option:selected').val() }));
                            }
                            szcs_cd.push(_.filter(data.rk_cd, { rk_cc_id: element.cc_id, rk_cd_id: $('.szcs_cd option:selected').val() }));
                        });
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>入库数量</th><th>商品库存</th><th>入库时间</th></tr></thead><tbody>'
                        _.flattenDeep(szcs_cd).forEach(element => {
                            if (parseInt(element.rk_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.rk_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                                var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.rk_number + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + (parseInt(element.rk_number) + parseInt(element.rk_curstock)) + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                        console.log($('.szcs_cd option:selected').val(), _.flattenDeep(szcs_cd), (new Date($('.qsrq').val()).getTime()));
                        // console.log(_.filter(data.storageData,{'cc_citycode':$('.szcs_id').val()}));
                    });
                } else if ($(this).val() == 3) {
                    var szcs = '<span>所在城市：</span><select class="szcs_id" style="margin-right:10px;margin-bottom:10px;"><option value="0">---请选择---</option>'
                    data.division.forEach(element => {
                        szcs += '<option value=' + element.cc_citycode + '>' + element.cc_city + '</option>'
                    });
                    szcs += '</select>'
                    var ccmc = '<span style="margin-left: 16px;">配送点：</span><select class="fzx_id" style="margin-right:42px;margin-bottom:10px;"><option value="0">---请选择---</option>'
                    // data.storageData.forEach(element => {
                    //     ccmc += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
                    // });
                    ccmc += '</select>'
                    var cd = '<span>商品：</span><select class="fzx_cd"><option value="0">所有商品</option>'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select><br>'
                    $('.cxtj_div2').html(szcs + ccmc + cd + date1 + '<button class="tj_fzx">查询</button>');
                    $('.szcs_id').change(function(){
                        var szcs_psd = _.filter(data.storageData,{cc_citycode:$(this).val()});
                        var ccname = '';//<option value="0">---请选择---</option>
                        szcs_psd.forEach(element => {
                            ccname += '<option value='+element.cc_id+'>'+element.cc_name+'</option>'
                        });
                        $('.fzx_id').html(ccname);
                    });
                    $('.tj_fzx').click(function () {
                        if($('.szcs_id').val() == 0){
                            alert('请选择所在城市');
                            return;
                        }
                        if ($('.qsrq').val() == '' || $('.jzrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.fzx_id option:selected').val(), rk_cd_id: $('.fzx_cd option:selected').val() });
                        if ($('.fzx_cd option:selected').val() == 0) {
                            fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.fzx_id option:selected').val() });
                        }
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>入库数量</th><th>商品库存</th><th>入库时间</th></tr></thead><tbody>'
                        fzx_cd.forEach(element => {
                            if (parseInt(element.rk_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.rk_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                                var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.rk_number + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + (parseInt(element.rk_number) + parseInt(element.rk_curstock)) + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                    });
                } else if ($(this).val() == 4) {
                    var cd = '<span style="margin-left:32px;">商品：</span><select class="fzx_cd">'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select>'
                    var ccmc = '<span style="margin-left: 26px;">配送点：</span><select class="fzx_id" style="margin-bottom:10px;"><option value="0">全部</option>'
                    data.storageData.forEach(element => {
                        ccmc += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
                    });
                    ccmc += '</select><br>'

                    $('.cxtj_div2').html(cd + ccmc + date1 + '<button class="tj_fzx">查询</button>');
                    $('.tj_fzx').click(function () {
                        if ($('.qsrq').val() == '' || $('.jzrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.fzx_id option:selected').val(), rk_cd_id: $('.fzx_cd option:selected').val() });
                        if ($('.fzx_id option:selected').val() == 0) {
                            fzx_cd = _.filter(data.rk_cd, { rk_cd_id: $('.fzx_cd option:selected').val() });
                        }
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>入库数量</th><th>商品库存</th><th>入库时间</th></tr></thead><tbody>'
                        fzx_cd.forEach(element => {
                            if (parseInt(element.rk_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.rk_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                                var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.rk_number + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + (parseInt(element.rk_number) + parseInt(element.rk_curstock)) + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                    });
                }
            });
        });
        
        $('.ul_li_ck').click(function () {
            $('.spxx').show();
            $('.psdxx').hide();
            $(this).addClass('active5').siblings().removeClass('active5');
            $('.cxtj_div1 select').val(0);
            $('.cb_tj_table').show();
            $('.jjx').hide();
            $('.header_table div').html('商品出库统计');
            $('.cxtj_div1 select').change(function () {
                var date20 = '<span>起始日期：</span><input type="date" class="qsrq" /><span>截止日期：</span><input type="date" class="jzrq" />'
                if ($(this).val() == 1) {
                    $('.cxtj_div2').html(date20 + '<button class="tj_lyzx2">查询</button>');
                    $('.tj_lyzx2').click(function () {
                        if ((new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var cd_ck_table = '<thead><tr><th>商品名称</th><th>出库数量</th><th>出库时间</th></tr></thead><tbody>'

                        data.cd_cd_ck.forEach(element => {
                            // var date5 = _.filter(data.rk_cd,{rk_cd_id:element.cd_id});
                            // var date4 = new Date(element.cd_rk_date);
                            // console.log(date5);
                            // for(i=0;i<date5.length;i++){
                            if (parseInt(element.cd_rk_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.cd_rk_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var date6 = _.join([new Date(element.cd_rk_date).getFullYear(), new Date(element.cd_rk_date).getMonth() + 1, new Date(element.cd_rk_date).getDate()], '-');

                                cd_ck_table += '<tr><td>' + element.cd_name + '</td>'
                                    + '<td>' + element.cd_number + element.cd_unit + '</td>'
                                    + '<td>' + date6 + '</td></tr>'
                            }
                            // }

                        });
                        cd_ck_table += '</tbody>';
                        $('.tj_table').html('');
                        $('.tj_table').html(cd_ck_table);
                    });
                } else if ($(this).val() == 2) {
                    var szcs = '<span>所在城市：</span><select class="szcs_id" style="margin-right:42px;margin-bottom:10px;">'
                    data.division.forEach(element => {
                        szcs += '<option value=' + element.cc_citycode + '>' + element.cc_city + '</option>'
                    });
                    szcs += '</select>'
                    var cd = '<span>商品：</span><select class="szcs_cd"><option value="0">所有商品</option>'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select><br>'
                    $('.cxtj_div2').html(szcs + cd + date20 + '<button class="tj_szcs">查询</button>');

                    $('.tj_szcs').click(function () {

                        if ($('.qsrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var szcs_cc = _.filter(data.storageData, { 'cc_citycode': $('.szcs_id').val() });
                        var szcs_cd = [];
                        console.log(szcs_cc);
                        szcs_cc.forEach(element => {
                            if ($('.szcs_cd option:selected').val() == 0) {
                                szcs_cd.push(_.filter(data.ck_cd, { ck_cc_id: element.cc_id }));
                            } else {
                                szcs_cd.push(_.filter(data.ck_cd, { ck_cc_id: element.cc_id, ck_cd_id: $('.szcs_cd option:selected').val() }));
                            }
                            szcs_cd.push(_.filter(data.ck_cd, { ck_cc_id: element.cc_id, ck_cd_id: $('.szcs_cd option:selected').val() }));
                        });
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>出存数量</th><th>入库时间</th></tr></thead><tbody>'
                        _.flattenDeep(szcs_cd).forEach(element => {
                            if (parseInt(element.ck_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.ck_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.ck_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.ck_cd_id });
                                var tj_date = _.join([new Date(element.ck_date).getFullYear(), new Date(element.ck_date).getMonth() + 1, new Date(element.ck_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.ck_number + tj_cd_name[0].cd_unit + '</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                        console.log($('.szcs_cd option:selected').val(), _.flattenDeep(szcs_cd), (new Date($('.qsrq').val()).getTime()));
                        // console.log(_.filter(data.storageData,{'cc_citycode':$('.szcs_id').val()}));
                    });
                } else if ($(this).val() == 3) {
                    var szcs = '<span>所在城市：</span><select class="szcs_id" style="margin-right:10px;margin-bottom:10px;"><option value="0">---请选择---</option>'
                    data.division.forEach(element => {
                        szcs += '<option value=' + element.cc_citycode + '>' + element.cc_city + '</option>'
                    });
                    szcs += '</select>'
                    var ccmc = '<span style="margin-left: 16px;">配送点：</span><select class="fzx_id" style="margin-right:42px;margin-bottom:10px;">'
                    // data.storageData.forEach(element => {
                    //     ccmc += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
                    // });
                    ccmc += '</select>'
                    var cd = '<span>商品：</span><select class="fzx_cd"><option value="0">所有商品</option>'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select><br>'
                    $('.cxtj_div2').html(szcs + ccmc + cd + date20 + '<button class="tj_fzx">查询</button>');
                    $('.szcs_id').change(function(){
                        var szcs_psd = _.filter(data.storageData,{cc_citycode:$(this).val()});
                        var ccname = '';//<option value="0">---请选择---</option>
                        szcs_psd.forEach(element => {
                            ccname += '<option value='+element.cc_id+'>'+element.cc_name+'</option>'
                        });
                        $('.fzx_id').html(ccname);
                    });
                    $('.tj_fzx').click(function () {
                        if($('.szcs_id').val() == 0){
                            alert('请选择所在城市');
                            return;
                        }
                        if ($('.qsrq').val() == '' || $('.jzrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var fzx_cd = _.filter(data.ck_cd, { ck_cc_id: $('.fzx_id option:selected').val(), ck_cd_id: $('.fzx_cd option:selected').val() });
                        if ($('.fzx_cd option:selected').val() == 0) {
                            fzx_cd = _.filter(data.ck_cd, { ck_cc_id: $('.fzx_id option:selected').val() });
                        }
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>出库数量</th><th>入库时间</th></tr></thead><tbody>'
                        fzx_cd.forEach(element => {
                            if (parseInt(element.ck_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.ck_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.ck_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.ck_cd_id });
                                var tj_date = _.join([new Date(element.ck_date).getFullYear(), new Date(element.ck_date).getMonth() + 1, new Date(element.ck_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.ck_number + tj_cd_name[0].cd_unit + '</td>'
                                    // + '<td>'+(parseInt(element.ck_number) + parseInt(element.ck_curstock))+tj_cd_name[0].cd_unit+'</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                    });
                } else if ($(this).val() == 4) {
                    var cd = '<span style="margin-left:32px;">商品：</span><select class="fzx_cd">'
                    data.cd_data.forEach(element => {
                        cd += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
                    });
                    cd += '</select>'
                    var ccmc = '<span style="margin-left: 26px;">配送点：</span><select class="fzx_id" style="margin-bottom:10px;"><option value="0">全部</option>'
                    data.storageData.forEach(element => {
                        ccmc += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
                    });
                    ccmc += '</select><br>'

                    $('.cxtj_div2').html(cd + ccmc + date20 + '<button class="tj_fzx">查询</button>');
                    $('.tj_fzx').click(function () {
                        if ($('.qsrq').val() == '' || $('.jzrq').val() == '' || (new Date($('.qsrq').val()).getTime()) > (new Date($('.jzrq').val()).getTime())) {
                            alert('日期选择错误！');
                            return;
                        }
                        var fzx_cd = _.filter(data.ck_cd, { ck_cc_id: $('.fzx_id option:selected').val(), ck_cd_id: $('.fzx_cd option:selected').val() });
                        if ($('.fzx_id option:selected').val() == 0) {
                            fzx_cd = _.filter(data.ck_cd, { ck_cd_id: $('.fzx_cd option:selected').val() });
                        }
                        var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>出库数量</th><th>入库时间</th></tr></thead><tbody>'
                        fzx_cd.forEach(element => {
                            if (parseInt(element.ck_date) > parseInt(new Date($('.qsrq').val()).getTime()) && parseInt(element.ck_date) < parseInt(new Date($('.jzrq').val()).getTime())) {
                                var tj_cc_name = _.filter(data.storageData, { cc_id: element.ck_cc_id });
                                var tj_cd_name = _.filter(data.cd_data, { cd_id: element.ck_cd_id });
                                var tj_date = _.join([new Date(element.ck_date).getFullYear(), new Date(element.ck_date).getMonth() + 1, new Date(element.ck_date).getDate()], '-');
                                tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                    + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                    + '<td>' + element.ck_number + tj_cd_name[0].cd_unit + '</td>'
                                    // + '<td>'+(parseInt(element.ck_number) + parseInt(element.ck_curstock))+tj_cd_name[0].cd_unit+'</td>'
                                    + '<td>' + tj_date + '</td></tr>'
                            }
                        });
                        tj_table += '</tbody>';
                        $('.tj_table').html(tj_table);
                    });
                }
            });
        });
        $('.ul_li_jjxg').click(function () {
            $('.spxx').show();
            $('.psdxx').hide();
            $(this).addClass('active5').siblings().removeClass('active5');
            $('.cb_tj_table').hide();
            $('.jjx').show();
            $('.header_table div').html('警戒线高库存');
            // $('.jjx_div1 span').html('警戒线高库存：');
            // var jjxg = '<span>警戒线高库存：</span><input type="number" />'
            var date2 = '<span>起始日期：</span><input type="date" class="qsrq_jj" /><span>截止日期：</span><input type="date" class="jzrq_jj" />'
            var ccmc_jj = '<span style="margin-left: 16px;">配送点：</span><select class="jj_id" style="margin-right:42px;margin-bottom:10px;"><option value="0">全部</option>'
            data.storageData.forEach(element => {
                ccmc_jj += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
            });
            ccmc_jj += '</select>'
            var cd_jj = '<span>商品：</span><select class="jj_cd"><option value="0">所有商品</option>'
            data.cd_data.forEach(element => {
                cd_jj += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
            });
            cd_jj += '</select>'
            $('.jjx_div2').html(ccmc_jj + cd_jj + '<button class="tj_jjx">查询</button>');
            $('.tj_jjx').click(function () {
                // if ($('.qsrq_jj').val() == '' || $('.jzrq_jj').val() == '' || (new Date($('.qsrq_jj').val()).getTime()) > (new Date($('.jzrq_jj').val()).getTime())) {
                //     alert('日期选择错误！');
                //     return;
                // }
                // if ($('.jjx_div1 input').val() == '') {
                //     alert('不可为空！');
                //     return;
                // }
                var fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_id option:selected').val(), rk_cd_id: $('.jj_cd option:selected').val() });
                if ($('.jj_cd option:selected').val() == 0 && $('.jj_id option:selected').val() != 0) {
                    fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_id option:selected').val() });
                } else if ($('.jj_cd option:selected').val() == 0 && $('.jj_id option:selected').val() == 0) {
                    fzx_cd = data.rk_cd;
                } else if ($('.jj_cd option:selected').val() != 0 && $('.jj_id option:selected').val() == 0) {
                    fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_cd option:selected').val() });
                }
                console.log($('.jjx_div1 select').val(),data.rk_cd);
                if ($('.jjx_div1 select').val() == 1) {
                    var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>商品库存</th><th>警戒线高库存</th><th>时间</th></tr></thead><tbody>'
                    fzx_cd.forEach(element => {
                        console.log('123123',_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}));

                        if ((parseInt(element.rk_number) + parseInt(element.rk_curstock)) < 86 && parseInt(element.rk_date) == parseInt(_.maxBy(_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}),'rk_date').rk_date)) {
                            var number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            if(parseInt(element.rk_date) >= parseInt(_.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_date)){
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            }else{
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock) - _.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_number
                            }
                            var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                            var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                            var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                            tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                // + '<td>'+element.rk_number+tj_cd_name[0].cd_unit+'</td>'
                                + '<td>' + number + tj_cd_name[0].cd_unit + '</td>'
                                + '<td>86</td>'
                                + '<td>' + tj_date + '</td></tr>'
                        }
                        
                    });
                } else if ($('.jjx_div1 select').val() == 2) {
                    var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>商品库存</th><th>警戒线低库存</th><th>时间</th></tr></thead><tbody>'
                    fzx_cd.forEach(element => {
                        console.log('123123',element);
                        var number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            if(parseInt(element.rk_date) >= parseInt(_.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_date)){
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            }else{
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock) - _.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_number
                            }
                        if (number > 118 && parseInt(element.rk_date) == parseInt(_.maxBy(_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}),'rk_date').rk_date)) {                            
                            
                            var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                            var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                            var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                            tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                // + '<td>'+element.rk_number+tj_cd_name[0].cd_unit+'</td>'
                                + '<td>' + number + tj_cd_name[0].cd_unit + '</td>'
                                + '<td>118</td>'
                                + '<td>' + tj_date + '</td></tr>'
                        }
                        
                    });
                } else if ($('.jjx_div1 select').val() == 0){
                    var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>商品库存</th><th>警戒线库存</th><th>时间</th></tr></thead><tbody>'
                    fzx_cd.forEach(element => {
                        console.log('123123',_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}));

                        if ((parseInt(element.rk_number) + parseInt(element.rk_curstock)) < 86 && parseInt(element.rk_date) == parseInt(_.maxBy(_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}),'rk_date').rk_date)) {
                            var number1 = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            if(parseInt(element.rk_date) >= parseInt(_.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_date)){
                                number1 = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            }else{
                                number1 = parseInt(element.rk_number) + parseInt(element.rk_curstock) - _.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_number
                            }
                            var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                            var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                            var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                            tj_table += '<tr style="background:red;"><td>' + tj_cc_name[0].cc_name + '</td>'
                                + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                // + '<td>'+element.rk_number+tj_cd_name[0].cd_unit+'</td>'
                                + '<td>' + number1 + tj_cd_name[0].cd_unit + '</td>'
                                + '<td>86</td>'
                                + '<td>' + tj_date + '</td></tr>'
                        }

                        
                    });
                    fzx_cd.forEach(element => {
                        console.log('123123',element);
                        var number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            if(parseInt(element.rk_date) >= parseInt(_.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_date)){
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock);
                            }else{
                                number = parseInt(element.rk_number) + parseInt(element.rk_curstock) - _.maxBy(_.filter(data.ck_cd,{ck_cc_id:element.rk_cc_id,ck_cd_id:element.rk_cd_id}),'ck_date').ck_number
                            }
                        if (number > 118 && parseInt(element.rk_date) == parseInt(_.maxBy(_.filter(fzx_cd,{rk_cc_id:element.rk_cc_id,rk_cd_id:element.rk_cd_id}),'rk_date').rk_date)) {                            
                            
                            var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                            var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                            var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                            tj_table += '<tr style="background:#ffff00b3;"><td>' + tj_cc_name[0].cc_name + '</td>'
                                + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                // + '<td>'+element.rk_number+tj_cd_name[0].cd_unit+'</td>'
                                + '<td>' + number + tj_cd_name[0].cd_unit + '</td>'
                                + '<td>118</td>'
                                + '<td>' + tj_date + '</td></tr>'
                        }
                        
                    });
                }
                tj_table += '</tbody>';
                $('.tj_table').html(tj_table);
            });
        });
        $('.ul_li_jjxd').click(function () {
            $('.spxx').show();
            $('.psdxx').hide();
            $(this).addClass('active5').siblings().removeClass('active5');
            $('.cb_tj_table').hide();
            $('.jjx').show();
            $('.header_table div').html('警戒线低库存');
            $('.jjx_div1 span').html('警戒线低库存：');
            // var jjxg = '<span>警戒线高库存：</span><input type="number" />'
            var date2 = '<span>起始日期：</span><input type="date" class="qsrq_jj" /><span>截止日期：</span><input type="date" class="jzrq_jj" />'
            var ccmc_jj = '<span style="margin-left: 16px;">配送点：</span><select class="jj_id" style="margin-right:42px;margin-bottom:10px;"><option value="0">全部</option>'
            data.storageData.forEach(element => {
                ccmc_jj += '<option value=' + element.cc_id + '>' + element.cc_name + '</option>'
            });
            ccmc_jj += '</select>'
            var cd_jj = '<span>商品：</span><select class="jj_cd"><option value="0">所有商品</option>'
            data.cd_data.forEach(element => {
                cd_jj += '<option value=' + element.cd_id + '>' + element.cd_name + '</option>'
            });
            cd_jj += '</select><br>'
            $('.jjx_div2').html(ccmc_jj + cd_jj + date2 + '<button class="tj_jjx">查询</button>');
            $('.tj_jjx').click(function () {
                if ($('.qsrq_jj').val() == '' || $('.jzrq_jj').val() == '' || (new Date($('.qsrq_jj').val()).getTime()) > (new Date($('.jzrq_jj').val()).getTime())) {
                    alert('日期选择错误！');
                    return;
                }
                if ($('.jjx_div1 input').val() == '') {
                    alert('不可为空！');
                    return;
                }
                var fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_id option:selected').val(), rk_cd_id: $('.jj_cd option:selected').val() });
                if ($('.jj_cd option:selected').val() == 0 && $('.jj_id option:selected').val() != 0) {
                    fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_id option:selected').val() });
                } else if ($('.jj_cd option:selected').val() == 0 && $('.jj_id option:selected').val() == 0) {
                    fzx_cd = data.rk_cd;
                } else if ($('.jj_cd option:selected').val() != 0 && $('.jj_id option:selected').val() == 0) {
                    fzx_cd = _.filter(data.rk_cd, { rk_cc_id: $('.jj_cd option:selected').val() });
                }
                console.log($('.jjx_div1 input').val());
                var tj_table = '<thead><tr><th>仓储名称</th><th>商品名称</th><th>商品库存</th><th>入库时间</th></tr></thead><tbody>'
                fzx_cd.forEach(element => {
                    console.log(element);
                    if (parseInt(element.rk_date) > parseInt(new Date($('.qsrq_jj').val()).getTime()) && parseInt(element.rk_date) < parseInt(new Date($('.jzrq_jj').val()).getTime())) {
                        if ((parseInt(element.rk_number) + parseInt(element.rk_curstock)) > parseInt($('.jjx_div1 input').val())) {

                            var tj_cc_name = _.filter(data.storageData, { cc_id: element.rk_cc_id });
                            var tj_cd_name = _.filter(data.cd_data, { cd_id: element.rk_cd_id });
                            var tj_date = _.join([new Date(element.rk_date).getFullYear(), new Date(element.rk_date).getMonth() + 1, new Date(element.rk_date).getDate()], '-');
                            tj_table += '<tr><td>' + tj_cc_name[0].cc_name + '</td>'
                                + '<td>' + tj_cd_name[0].cd_name + '</td>'
                                // + '<td>'+element.rk_number+tj_cd_name[0].cd_unit+'</td>'
                                + '<td>' + (parseInt(element.rk_number) + parseInt(element.rk_curstock)) + tj_cd_name[0].cd_unit + '</td>'
                                + '<td>' + tj_date + '</td></tr>'
                        }
                    }
                });
                tj_table += '</tbody>';
                $('.tj_table').html(tj_table);
            });
        });
        $('.ul_li_psdxx').click(function(){
            $('.spxx').hide();
            $('.psdxx').show();
            $('.header_table div').html('配送点信息');
            $(this).addClass('active5').siblings().removeClass('active5');
            var psdxx = ''
            data.storageData.forEach(element => {
                psdxx += '<tr><td>'+element.cc_name+'</td>'
                    + '<td>'+element.cc_x+'</td>'
                    + '<td>'+element.cc_y+'</td>'
                    + '<td>'+element.cc_city+'</td>'
                    + '<td>'+element.cc_citycode+'</td>'
                    + '<td>'+element.cc_lxr+'</td>'
                    + '<td>'+element.cc_landline+'</td>'
                    + '<td>'+element.cc_mobilephone+'</td>'
                    + '<td>'+element.cc_postalcode+'</td>'
                    + '<td>'+element.cc_address+'</td></tr>'
            });
            $('#dataTable2 tbody').html(psdxx);
        });
        $('.ul_li_psdxx').click();
    }
     function animation() {

        function changeTrack(track){
            var routeCoords = track;
            
            map.getLayers().forEach(function (layer) {
                if (layer.getProperties().name != 'base_Layer2' && layer.getProperties().name != 'base_Layer1') {
                    map.removeLayer(layer);
                }

            });
            var routeLength = routeCoords.length;

            //  var routeFeature = new ol.Feature({
            //      type: 'route',
            //      geometry: route
            //  });
            var geoMarker = new ol.Feature({
                type: 'geoMarker',
                geometry: new ol.geom.Point(routeCoords[0])
            });
            // var startMarker = new ol.Feature({
            //     type: 'icon',
            //     geometry: new ol.geom.Point(routeCoords[0])
            // });
            // var endMarker = new ol.Feature({
            //     type: 'icon',
            //     geometry: new ol.geom.Point(routeCoords[routeLength - 1])
            // });
            vectorLayer10 = new ol.layer.Vector({
                name:'base_Layer5',
                source: new ol.source.Vector({
                    features: [geoMarker]
                }),
                style: function (feature) {
                    // hide geoMarker if animation is active
                    if (animating && feature.get('type') === 'geoMarker') {
                        return null;
                    }
                    return styles[feature.get('type')];
                }
            });
             map.addLayer(vectorLayer10)
            var styles = {
                 'route': new ol.style.Style({
                     stroke: new ol.style.Stroke({
                         width: 6, color: [237, 212, 0, 0.8]
                     })
                 }),
                 'icon': new ol.style.Style({
                     image: new ol.style.Icon({
                         anchor: [0.5, 1],
                         src: './images/icon.png'
                     })
                 }),
                'geoMarker': new ol.style.Style({
                    // image: new ol.style.Circle({
                    //     radius: 7,
                    //     fill: new ol.style.Fill({ color: 'black' }),
                    //     stroke: new ol.style.Stroke({
                    //         color: 'red', width: 2
                    //     })
                    // })
                    image: new ol.style.Icon({
                         anchor: [0.5, 1],
                         src: './images/icon.png'
                     })
                })
            };

            var animating = false;
            var speed, now;
            var startButton = document.getElementById('start-animation');

            var moveFeature = function (event) {

                var vectorContext = event.vectorContext;
                var frameState = event.frameState;

                if (animating) {
                    var elapsedTime = frameState.time - now;
                    // here the trick to increase speed is to jump some indexes
                    // on lineString coordinates
                    var index = Math.round(speed * elapsedTime / 1000);

                    if (index >= routeLength) {
                        stopAnimation(true);
                        return;
                    }

                    var currentPoint = new ol.geom.Point(routeCoords[index]);
                    var feature = new ol.Feature(currentPoint);
                    vectorContext.drawFeature(feature, styles.geoMarker);
                }
                // tell OpenLayers to continue the postcompose animation
                map.render();
            };

            function startAnimation() {
                
                if (animating) {
                    stopAnimation(false);
                } else {
                    vectorLayer10.setVisible(true);
                    animating = true;
                    now = new Date().getTime();
                    speed = 1.2;
                    //  startButton.textContent = 'Cancel Animation';
                    // hide geoMarker
                    geoMarker.setStyle(null);
                    // just in case you pan somewhere else
                    //  map.getView().setCenter(routeCoords[0])6
                    map.getView().animate({
                        center: routeCoords[0],
                        duration: 0,
                        zoom: 10,
                    });
                    map.on('postcompose', moveFeature);
                    map.render();
                }
            }
            function stopAnimation(ended) {
                animating = false;
                //  startButton.textContent = 'Start Animation';

                // if animation cancelled set the marker at the beginning
                var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
        /** @type {module:ol/geom/Point~Point} */ (geoMarker.getGeometry())
                    .setCoordinates(coord);
                //remove listener
                map.un('postcompose', moveFeature);
            }
            startButton.addEventListener('click', startAnimation, false)
            //  $('#start-animation').click(function(){
            //      startAnimation();
            //  })
            // });  
        }
         $('#selectChe').change(function(){
             $(".yxMap").click();
             if($(this).val() == 1){
                 changeTrack(track1);
             } else if ($(this).val() == 2) {
                 changeTrack(track2);
             }
         });
         
    }
 })
 
